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?

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:

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++?

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.

I really just know the libraries, but if there are issues like that I might just do it in C++.

Did you ever use “Xamarin” ?
Xamarin is absurdly easy to use.

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++.

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.

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 Calling C/C++ libraries from Xamarin code | Kerry's Blog)

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.

Interesting. I’ll keep my eye out for that. Thanks for the info :slight_smile:

Thanks for the info :slight_smile:

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