Announcement

Collapse
No announcement yet.

Creating a C# DLL for SQL interaction

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Creating a C# DLL for SQL interaction

    I would like to create a C# file to handle retreiving data from an online SQL databse.

    Is there a way I can add this file to my UE4 project and use its functionallity?

    #2
    If you're targeting Windows only, it's very easy to do it using VSC++ CLI.
    CLI automatically bridges (marshaling) .NET types to and from native C++ for you, then can you easily transfer data back and forth into Unreal via DLLs:

    https://docs.microsoft.com/en-us/cpp...p?view=vs-2017
    | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

    Comment


      #3
      I went down the CLI route a few years ago and it was a nightmare with Unreal. Real ugly code and hard to debug.

      Why not just connect to DB with C++?

      Comment


        #4
        The CLI route in general can be a nightmare regardless of whether you are using unreal or not. I generally try to use PInvoke first until I really start to need to be stateful but CLI is always my last choice for interop.

        If you make a rest interface for said database you might be able to get around making a wrapper. How are you accessing the database? Directly with SQL? EF?

        Comment


          #5
          Originally posted by AlexM View Post
          The CLI route in general can be a nightmare regardless of whether you are using unreal or not. I generally try to use PInvoke first until I really start to need to be stateful but CLI is always my last choice for interop.

          If you make a rest interface for said database you might be able to get around making a wrapper. How are you accessing the database? Directly with SQL? EF?
          I was planning on making a direct connection but a REST interface is quite a good idea actually. Thanks.


          Originally posted by Jocko Jonson View Post
          I went down the CLI route a few years ago and it was a nightmare with Unreal. Real ugly code and hard to debug.

          Why not just connect to DB with C++?
          I really just know the libraries, but if there are issues like that I might just do it in C++.

          Comment


            #6
            Originally posted by Jocko Jonson View Post
            I went down the CLI route a few years ago and it was a nightmare with Unreal. Real ugly code and hard to debug.
            Did you ever use "Xamarin" ?
            Xamarin is absurdly easy to use.
            | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

            Comment


              #7
              What does Xamarin have to do with the CLI?

              Xamarin is a company that maintains mono and makes xamarin forms. The CLI is one of the 3 methods (maybe there are more these days) to bind C# to C/C++.

              Comment


                #8
                Xamarin can be used to do the exactly same thing.
                You can write .NET code in it and call it from C++ without worrying about marshaling .NET types.
                Some people use it to create their own mobile engines for iOS/Android.
                | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

                Comment


                  #9
                  Xamarin made yet another binding layer? Interesting.

                  an you give me a link to it? I can't seem to find it on their website. I would love to not have to worry about marshalling so much.

                  EDIT : I googled around and all the examples seem to just be using p/invoke (EX https://kerry.lothrop.de/c-libraries/)
                  Last edited by AlexM; 11-28-2018, 06:41 PM.

                  Comment


                    #10
                    Now I don't know if what I've seen was built-in in Xamarin or they built that themselves, but in the custom engine they were showing me there was no need to do any manual marshaling for .NET types..
                    "because Xamarin/Mono makes easy to do that" I was told.
                    | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

                    Comment


                      #11
                      Interesting. I'll keep my eye out for that. Thanks for the info

                      Comment


                        #12
                        Thanks for the info

                        Comment


                          #13
                          Originally posted by BrUnO XaVIeR View Post
                          If you're targeting Windows only, it's very easy to do it using VSC++ CLI.
                          CLI automatically bridges (marshaling) .NET types to and from native C++ for you, then can you easily transfer data back and forth into Unreal via DLLs:

                          https://docs.microsoft.com/en-us/cpp...p?view=vs-2017
                          Hi, gentleman, help me please.

                          I need to load a method in C# dll. this method like this : public List<User> GetAllUser(). right, this method return value is very complex. I know how to load a method that return simple value like float, string, int.

                          but List<User>, I can't.

                          User is a C# class.

                          So, help me please. thanks


                          Comment

                          Working...
                          X