Reputation: 716
I've got the following function in a C++/CLI class library DLL:
public delegate void StandardOutputError(String^ Message);
bool foo(System::String^% arg1, System::String^% arg2, System::String^% arg3, StandardOutputError^ Output);
How would I go about exporting it so that it can be called by arbitrary managed (C++/CLI) code ? My primary concern is the delegate argument - Would it be possible to safely convert it to a function pointer and back (that is if it isn't possible to directly export __clrcall functions) ?
Upvotes: 1
Views: 213
Reputation: 62975
As long as foo
is inside a public managed type, you can add a reference to your C++/CLI assembly and use it from e.g. C# just as you would any other managed assembly. The StandardOutputError
delegate is already fine.
The larger point is, managed types are exported in .NET metadata just by virtue of being managed types and compiling with /clr. No __declspec(dllexport)
shenanigans necessary.
Upvotes: 2