The problem of accessibility of the global C ++ / CLI function

How can I make a C ++ / CLI function visible when a compiled DLL is imported into C #?

I can do this with classes by simply specifying their name publicly, but this does not apply to functions, and I get a syntax error when I do this.

How can i do this?

Thank!

+3
source share
1 answer

You cannot, the CLR does not support global functions. You can write them in C ++ / CLI, but the compiler generates a special class to give them a home. The name of the class <Module>, it is not accessible from C # code.

, ref . . , #, . , :

public ref class Utils abstract sealed
{
public:
    void static foo() {}
};
+8

All Articles