Exporting function from a C# dll with __stdcall calling convention
-
Hi, I'm a newbie in C#. I want to create a C# dll exporting some functions to be used from a thirdy party application. This application can call functions exported froma DLL but those functions have to be declared as __stdcall. Is there a simple way to export functions froma C# dll as __stdcall (or in a way it works as __stdcall) ? Thanks
-
Hi, I'm a newbie in C#. I want to create a C# dll exporting some functions to be used from a thirdy party application. This application can call functions exported froma DLL but those functions have to be declared as __stdcall. Is there a simple way to export functions froma C# dll as __stdcall (or in a way it works as __stdcall) ? Thanks
Hi! No, there is no way to export a __stdcall function from a C# assembly, because of several reasons. One of the reasons is that you can't have "functions" outside a class in C#, another one is that all C# methods rely on the CLR interpreting them. You have to create a C++ DLL to do this. Fortunately, you can quite easily access your C# classes from a mixed mode C++ DLL, so it should be possible to create some kind of wrapper to expose a call to a method written in C# for an unmanaged callee.
Regards, mav -- Black holes are the places where God divided by 0...
-
Hi! No, there is no way to export a __stdcall function from a C# assembly, because of several reasons. One of the reasons is that you can't have "functions" outside a class in C#, another one is that all C# methods rely on the CLR interpreting them. You have to create a C++ DLL to do this. Fortunately, you can quite easily access your C# classes from a mixed mode C++ DLL, so it should be possible to create some kind of wrapper to expose a call to a method written in C# for an unmanaged callee.
Regards, mav -- Black holes are the places where God divided by 0...
The method of a wrapper c++ class was the first one I've thought and probably will be the final choice. Anothre question ... If a c# class method is declared as static, is it possible to export it in some way ?+ Thanks for your time
-
The method of a wrapper c++ class was the first one I've thought and probably will be the final choice. Anothre question ... If a c# class method is declared as static, is it possible to export it in some way ?+ Thanks for your time
Please see this answer[^]
Regards, mav -- Black holes are the places where God divided by 0...