C++调用C#的dll文件的另一个问题,急!!!
我用C#写了如下一个简单的.dll文件,存为TestForDll1.dll
程序如下:
using System;
namespace TestForDll1
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
public class TestForDll
{
private int result ;
public TestForDll()
{
result = 0;
}
public TestForDll(int a , int b)
{
result = 0;
result = a + b;
}
public int Out()
{
return result;
}
}
}
有用C++.net 创建一个工程,程序如下:
#include <iostream.h>
#using <TestForDll1.dll>
#using <mscorlib.dll>
using namespace System;
using namespace TestForDll1;
void main()
{
int i = 0;
TestForDll *a = new TestForDll(1,2);
i = a->Out();
cout<<"the result is"<<i<<endl;
}
并且将C#编写的TestForDll1.dll拷到这个工程的文件夹下,生成文件时很正常,
但运行时,出现错误"未处理的“System.IO.FileNotFoundException”类型的异常出现在 未知模块中
其他信息:找不到文件或程序集名称“TestForDll1”,或找不到它的一个依赖项。"
用编写过程我确信C++.net工程已经找到了TestForDll1.dll文件并且找到了她的namespace 、class 、method 等元素,但运行时为什么会出现错误???
请不吝赐教!!!
谢谢!!!