How called the dll(written by c++)by c#?

  • Thread starter Thread starter Bruce.Chenhj
  • Start date Start date
B

Bruce.Chenhj

Um,i search the problem through the internet.There is a code in *.cs:
using System.Runtime.InteropServices;
[DllImport("Test.DLL", EntryPoint="TestOne")]
public static extern bool TestOne(string src);
So,we can call the TestOne function.
But there is no DllImport() funtion,so can't execute the code.
Can someone tell me how can i do?
Thanks
Bruce Chen
 
Bruce,

Are you getting a compiler error or a runtime error?
 
Thanks Nicholas
I create a new project of ClassLibrary,and there is no errors in it.
This is the following code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace testlib
{
public class enterdll
{
[DllImport("Adv.dll", EntryPoint = "OnOpendevbutton",
ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]

public static extern void OnOpendevbutton();

}

}
and i put the adv.dll(it's in bin folder) in another project not in
the ClassLibrary project.
There is a error(can't find the 'OnOpendevbutton' EnterPoint in
'Adv.dll'.) when i debug the project.
By the way,there are some function(i want to call them by donet),and
include the OnOpendevbutton() function.
So, what i can do?
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top