日期:2014-05-18  浏览次数:20748 次

关于DLL引用的问题
想了解一下有关dll方面的知识。写了一段程序,编译成dll,引用后报错:无法在DLL中找到名SampleMethod(int i)为的入口点。其中SampleMethod(int i)为我程序中的一个方法。这是怎么回事?

------解决方案--------------------
有没有将它放入自己定义的类中`~?
------解决方案--------------------
本地dll的话,可能你没有正确导出SampleMethod(int i)。

托管dll的话,可能是可见范围问题(public,private)。
------解决方案--------------------
无法在DLL中找到名SampleMethod(int i)为的入口点
--------------------------------------------
估计没正确引入
------解决方案--------------------
使用DLL imPORT
  
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 

http://feiyun0112.cnblogs.com/
------解决方案--------------------
路过
  
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 

http://feiyun0112.cnblogs.com/
------解决方案--------------------
从托管应用程序调用非托管代码
当调用用户定义的 DLL 中所包含的函数时,有必要将 extern "C" 添加在 DLL 函数声明之前,如下所示:
The function declaration in SampleDLL.h file
extern "C" SAMPLEDLL_API int fnSampleDLL(void);

详见http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/vccore/html/vcwlksysimportattributetutorial.asp
------解决方案--------------------
.net中的class默认为internal,

你将class改为public再试吧
------解决方案--------------------
无法找到类说明dll没正确添加引用
无法在DLL中找到名SampleMethod(int i)为的入口点说明没有访问此方法的权限,private?/protect??
------解决方案--------------------
class 私有

public SampleMethod(int i)


------解决方案--------------------
C#调用C++编写的COM DLL  
http://www.cnblogs.com/tallman/archive/2007/04/27/729048.html
 
C#中调用C++的dll的参数为指针类型的导出函数(包括二级指针的情况)
[url=http://www.cppblog.com/kerlw/archive/2007/06/27/27061.html ]http://www.cppblog.com/kerlw/archive/2007/06/27/27061.html [/url]
------解决方案--------------------
你怎么引用的!
------解决方案--------------------
直接右键添加引用引用这个DLL。
在程序里:
C# code

Test test=new Test(); 
int aaa=   test.SampleMethod(1);

------解决方案--------------------
C#的DLL和windows的标准dll不是一样的东西,不能直接这么用。
------解决方案--------------------
public class Test

------解决方案--------------------
dll调用有问题
------解决方案--------------------
右击解决方案 添加项目引用
------解决方案--------------------
你写的这个DLL也是C#环境下编译成的,不是C/C++环境下编译成的,没有必要用下面的方法.
[DllImport("Add.dll",EntryPoint="SampleMethod")]
public static extern int SampleMethod(int i);

用下面的方法就可以了:
直接右键添加引用引用这个DLL。 
using ClassLibrary1;
namespace ConsoleApplication1
{
class Program
{
static int Main(string[] args)
{
Test test = new Test();
return test.SampleMethod(5);