gwin003
gwin003

Reputation: 7901

Call static C# method from C++

I have created a .netmodule from a C# class library. I am trying to call into a static C# method in the .netmodule from my C++ code. I cannot figure out the syntax (my C++ is weak)to do so. Here is my C# method.

namespace MyModule
{
    public static class VersionChecker
    {
        public static string GetDllVersion()
        {
            //do some stuff
            return version;
        }
    }
}

I have tried both solutions below...

MyModule::VersionChecker.GetDllVersion();
MyModule::VersionChecker->GetDllVersion();    

but I am getting the following error on both lines...

error C2143: syntax error : missing ';' before '.'

Or

error C2143: syntax error : missing ';' before '->'

Can anyone tell me how I can call the static method GetDllVersion from my C++ code?

Upvotes: 1

Views: 1365

Answers (2)

Leo Chapiro
Leo Chapiro

Reputation: 13984

Try this:

MyModule::VersionChecker::GetDllVersion();

Upvotes: 2

SLaks
SLaks

Reputation: 887315

In C++, all references to static members (or types) use :::

MyModule::VersionChecker::GetDllVersion();

Upvotes: 7

Related Questions