尝试创建 C++/CLI 程序集以在 .NET 中使用
我正在尝试将 C++ 库引入 C#,因此我自然会尝试创建一个 C++/CLI 项目。
在 Visual Studio 中我创建了一个新项目(Visual C++ 项目,类库)。然后我尝试从预先生成的“Class1”中创建一个测试类,
namespace Test {
public ref class TestIt {
public:
void DoWork() {
System::Console::WriteLine("sup");
}
// TODO: Add your methods for this class here.
};
}
因此我编译并转到构建文件夹.... hrmm no .dll wetf?有一个 .dll.intermediate.manifest 文件,但没有 .dll。
那么我做错了吗?
I'm trying to bring a C++ library into C#, so naturally I am trying to make a C++/CLI project.
In visual studio I created a new project (Visual C++ project, class library). I then tried to make a test class out of the pre-generated "Class1"
namespace Test {
public ref class TestIt {
public:
void DoWork() {
System::Console::WriteLine("sup");
}
// TODO: Add your methods for this class here.
};
}
So I compile in and go to the build folder.... hrmm no .dll wetf?? There's a .dll.intermediate.manifest file, but no .dll.
So wut I did wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这将需要一些心理调试。或者网络摄像头。我猜您已将此项目添加到现有解决方案中。在这种情况下,您将在解决方案文件夹的 Debug 子目录中找到该 DLL,而不是项目的 Debug 文件夹。
要将其放在正确的位置,请右键单击需要 DLL 的项目,添加引用,项目选项卡,选择您的 C++/CLI 项目。现在它将被复制到 C# 项目的 bin\Debug 文件夹中,以供 C# 项目使用它。
This is going to require some psychic debugging. Or a web cam. I'll guess that you added this project to an existing solution. In which case you'll find the DLL in the Debug subdirectory of the solution folder, not the Debug folder of your project.
To get it in the right place, right-click the project that needs the DLL, Add Reference, Project tab, select your C++/CLI project. Now it will get copied in the bin\Debug folder of your C# project, ready for your C# project to use it.
您可以在当前项目文件中创建新的 CLR dll 类型解决方案。编译,你会得到一个dll文件。
You can create a new CLR dll type solution, within your current project file. Compile, and you'll get a dll file.