Yashodhar.Rao
Yashodhar.Rao

Reputation: 107

"Unable to find an entry point named" in c# using a C dll

I am trying a simple program to access a C function through a dll into a C# program,

class DllImportTest
{
    [DllImport("TestApp.dll", EntryPoint = "main1")]
    public static extern void main1();
}

class Program
{
    static void Main(string[] args)
    {
        DllImportTest.main1() ;
    }

I have seen through the code and the name of the function is the exactly right. I have also tried using Extern "C" but, it throws me an error as its .C file. I have placed the .Dll in the C# executable folder. Is there something that I am doing wrong here?

Upvotes: 3

Views: 5332

Answers (1)

Yashodhar.Rao
Yashodhar.Rao

Reputation: 107

Found it! I had to use Extern "C" coupled with __declspec(dllexport) . I had never used both together, Thanks guys

Upvotes: 3

Related Questions