How can I make a C++/CLI function visible, when the compiled DLL is imported in C#?
I can do it with classes simply by preceding their name with public, but its not the case with functions and I get syntax error when I do so.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t, 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 class name is
<Module>, it is not accessible from C# code.You’ll get the exact equivalent by declaring a public ref class with public static methods. No trouble accessing those. Same idea as a static class in C#, minus the checks. You can add the checks by declaring it abstract and sealed: