托管dll中找不到入口点

托管dll中找不到入口点

问题描述:

大家好

当我在c中创建托管dll并在c#中使用此托管dll时
那么我必须面对找不到的错误入口点

在托管dll中,我不能使用与非托管dll中的goiong相同的过程

请帮助我在c#中使用c的托管dll

致谢

Hi all

when i create managed dll in c and used this managed dll in c#
then i have to face the error entry point not found

in managed dll i cant not use the same procedure which is goiong to use in unmanaged dll

kindly help me hoe to use the managed dll of c in c#

Kind Regards

您要执行的操作是P/Invoke. (请阅读我对Abhinav答案的评论;希望我理解您的问题.如果这是关于在非托管代码中使用托管程序集的话,我也知道更好的答案.)

您需要将static extern声明与System.Runtime.InteropServices.DllImportAttribute一起使用.请参阅 http://msdn.microsoft.com/en-us/library/system .runtime.interopservices.dllimportattribute.aspx [ ^ ]和一些代码示例.

实际上,根据要公开的方法,P/Invoke可能很容易,也可能非常困难.您需要考虑许多细节:调用约定,针对不同类型的封送处理,参数传递的不同方法等等.

从这里开始了解它:
http://msdn.microsoft.com/en-us/library/aa719104%28v = vs.71%29.aspx [ ^ ],
另请参阅: http://msdn.microsoft.com/en-us/library/system .runtime.interopservices.aspx [ ^ ].

-SA
What you trying to do is P/Invoke. (Read my comment to the answer by Abhinav; I hope I understand your question. If this is about using managed assembly in unmanaged code, I also know better answer.)

You need to use static extern declaration with System.Runtime.InteropServices.DllImportAttribute. See http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.aspx[^] with some code sample.

Actually, P/Invoke can be easy or extremely difficult, depending on methods you want to expose. There are many details you need to take into account: calling conventions, marshaling for different types, different methods of parameter passing and more.

Start to learn about it here:
http://msdn.microsoft.com/en-us/library/aa719104%28v=vs.71%29.aspx[^],
See also: http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.aspx[^].

—SA


您不能在非托管代码中直接使用托管dll.
您需要围绕托管dll构建COM可调用包装器,然后将其添加为对非托管代码的引用.

COM可调用包装 [
You cannot directly use a managed dll in unmanaged code.
You need to build a COM callable wrapper around the managed dll and then add this as reference to your unmanaged code.

Read more about this at COM Callable Wrapper[^].