tags:

views:

175

answers:

3

I am attempting to write a C# application connecting to a Cognos TM1 datastore using the tm1api.dll. I have created a basic shell project in VS C# Express 2008, and added the following code

public partial class MainPortal : Window
{

    [System.Runtime.InteropServices.DllImport(@"C:\\Program Files\\Cognos\\TM1\\bin\\tm1api.dll", EntryPoint="TM1APIInitialise")]
    public static extern void TM1APIInitialise();

    public MainPortal()
    {
        InitializeComponent();

        TM1APIInitialise();
    }
}

I can build this project with no errors, but when running I get the following error:

"Unable to find an entry point named 'TM1APIInitialise' in DLL 'C:\\Program Files\\Cognos\\TM1\\bin\\tm1api.dll'."

I have used 'dumpbin /exports tm1api.dll' to determine its entry point:

    101   5D 00008360 TM1APIFinalize

Now I am at a loss, it seems to have an entry point but does recognize it. Can anyone point me in the right direction?

PS. I am completely new to C#, so I may be making extremely basic mistakes :)

+1  A: 

try this

public partial class MainPortal : Window
{

    [System.Runtime.InteropServices.DllImport(@"C:\Program Files\Cognos\TM1\bin\tm1api.dll", EntryPoint="TM1APIFinalize")]
    public static extern void TM1APIFinalize();

    public MainPortal()
    {
        InitializeComponent();

        TM1APIInitialise();
    }
}
ArsenMkrt
+1  A: 

It appears you have the name of the entrypoint wrong "TM1APIInitialise" versus "TM1APIFinalize". Also, you don't need to escape the backslashes \ if you use the string literal @.

JP Alioto
A: 

Thanks JP and ArsenMkrt, your answers both lead to me working out the issue.

I had it defined as TM1APIInitialise and it should have been TM1APIInitialize.

Note the 's' instead of the 'z' (damn American spelling) :).

Craig T