3

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?

4

1 に答える 1

3

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

于 2012-07-12T04:55:48.620 に答える