How to wrap C++ boost::variant in C++/CLI to grant access from .NET - c++-cli

I am wrapping a C++ library to C++/CLI to call the functionality from .Net. The C++ library has a type using command = boost::variant<assignment, identifier, decimal> and wonder how to wrap it.
I searched the web but couldnt find anything. And idea is appreciated.

Related

I made a project in C++ CLI, But I can decompile it using a C# Decompiler

Is there any way, I can prevent my c++ cli project from being decompiled if someone uses a C# decompiler, because I tried to decompile the .exe i made in ILSpy and it showed my whole code, so is there any way I can prevent this?
Thanks
as ancient as this thread is, I ran across it with the same question, and a newish answer. Can't specify the minimum version for this one, but
[module:System::Runtime::CompilerServices::SuppressIldasmAttribute];
on top of each .cpp module did the trick for me:
I didn't investigate much further, yet.
Another useful thing is to add
#pragma unmanaged
to each .cpp that does not contain .net code.
You can
Use a .NET obfuscator.
Or
Only use C++CLI for the boundaries of your app which require to Interact with .NET. And implement your logic in a native C++ library.

Can a C/C++ program be compiled into a .NET portable class library using C++/CLI

I've read the documentation on .NET programming in C++/CLI, and understand at a high level that it can compile C or C++ to .NET MSIL. I also understand that native structures are translated in the process.
The question is, can I compile a C/C++ codebase into a .NET Portable Class Library using C++/CLI? The intention is to use the result across various platforms, e.g. the Xamarin platforms and UWP.
Edit: Is it easier to do this for plain C, rather than C++?
Short answer: AFAIK no.
Long answer:
As far as I know the C++/CLI source code is compiled in "mixed" mode. It means that if you learn C++/CLI language and create managed classes with it, they run in .NET natively. That's good. But if you simply take your existing C++ code and compile it, the result is the native x86/Windows code, which cannot be used on other platforms. It is called "mixed" because the compiler puts native and .NET IL code together to single executable file.
C++/CLI is usually used in situations where you want to use the existing C++ code
as a part of .NET program in Windows. So you create a library in C++/CLI and create an interface for it in managed C++/CLI. This managed C++/CLI interface is a bridge between native C++ code and the rest of your program in .NET.
Also, as far as I know, C++/CLI is generally not supported by CoreCLR.

vb.net: is it possible to import FreeImage.dll to vb.net?

I need to read\write tga files from vb,
I found TargaImage.dll, nice lib but it allows only read tga.
I found FreeImage, tryed to import it in vb, but it says:
FreeImage.dll could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.
I think I have to use , but absolutly dont know anything.
help plz:)
From looking at the way the distribution works, you have two options:
First, you could call the functions in the DLL directly using <DllImport> attributes. This is going to require a lot of learning of how to make calls to unmanaged DLLs, passing the right values, etc. Which is why I suggest the second option.
The second option is, you can use the .NET Wrapper project that is included in the distribution. If you're using a version of Visual Studio that supports multiple programming languages, just add the wrapper project to your solution and reference the wrapper project from the project that needs to use it.
If you're using Visual Studio Express, you won't be able to add a C# project to a VB solution. I'd suggest downloading C# Express, compiling the wrapper project, and then adding the compiled DLL to your VB.Net project.

link dll functions at runtime

My program requires some function in a dll at runtime. How do I tell where the dll is? I can copy the dll into the program directory or system 32. Is there other neat way of doing this? Thank you. Also I am working in C++.
Are you using native code (C/C++/Delphi) or .NET? You should see my answer to Call Function from Dynamic Library for an example of how to do this with a native (not .NET) DLL.

VB6 - Lua Integration

I'm wondering if anyone has any tips for integrating Lua and VB6. I am running a small Online RPG that would be awesome to add some scripting to.
Well, it is doable. I once did it for Lua 5.0.2 but I can't find the files. Among the options you have, you can:
Wrap Lua in a COM dll exposing the Lua API, so in VB you can add a reference to it.
Build your custom Lua version, using the __stdcall calling convention, so you can use Declare in VB to import the needed Lua functions. Writing a Type Library will ease a lot the integration with VB (mainly, it will do the conversion from C strings to VB strings for you).
Build a wrapper DLL, that replicates Lua's interface but using __stdcall, adding the functions that are defined with macros, etc.
I remember that using a custom built Lua, I could register VB functions (defined in modules) into Lua and call them from a script. I don't recall if I ever got it to call member functions.
I hope this can get you started.
Use LuaInterface. It's a .NET Library that allows you to use lua. However it doesnt come with docs in and of itself, look at this for some helpful guides.
Basically, you add the DLL to your project and reference it/add using satements, then create a new Lua object. From there, you can access it like an array to extract variables, and there are methods to call lua functions and manipulate tables.