How to call C# function from unmanaged C++ code.?
-
Hi, I need to call a function written in C# from the unmanaged code. The code from where I have to call the function is purely written in VC++ and it come in the unmaged part of the solution code. Most of the solution is written in C# .NET 3.5. Please help me out. Thanks In Advance Abbas
-
Hi, I need to call a function written in C# from the unmanaged code. The code from where I have to call the function is purely written in VC++ and it come in the unmaged part of the solution code. Most of the solution is written in C# .NET 3.5. Please help me out. Thanks In Advance Abbas
So you need P/Invoke, make sure any objects (arrays) you pass get properly pinned, and pass a delegate. All you need should be in my article here[^]. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
Hi, I need to call a function written in C# from the unmanaged code. The code from where I have to call the function is purely written in VC++ and it come in the unmaged part of the solution code. Most of the solution is written in C# .NET 3.5. Please help me out. Thanks In Advance Abbas
To call the method directly, you're realistically limited to using COM. This means you need to expose you .NET object as a COM object and import the type library into your VC++ application.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.