Hi @Code Wanderer ,
For calling C# DLL you can refer to the COM method in the link.The tlb file is a com type library file, which contains interface-related information and is called by "#import xxx.tlb".
- You need to set the C# DLL to be registered for com interop.
- Copy the regasm.exe file to the dll directory.
- Open CMD, cd into the directory where the dll is located, and enter the command:
regasm XXX.dll /tlb
- Import it into the C++ project with #import directive. ( #import "../../XXX/debug/XXX.tlb")
Other questions about you:
Using the CLR with reference to this link is a good approach, but it won't work cross-platform.
You could write classes in a C# DLL and call them in C++, similarly, you could write functions in a C++ DLL and call them in C#, but I think you could write in C++ what needs to be called from C++, And write what needs to be called in C# in C#.
Best regards,
Elya
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hi @Code Wanderer ,
In theory, COM is cross-platform, but in implementation it relies on Windows. You could refer to the suggestion in this issue.
Hi @Code Wanderer ,
May I know if you have got any chance to check my comment? I am glad to help if you have any other questions.
Thanks, Yes I checkd it, but I need a more time to read, From quick look, unfortunately I am not more wise. I found that I can call Net Host from native code, which looks interesting, but I am not sure if I need it, while I can do it without hosting and load DLL and call the static exported functions.
Sign in to comment