大家好! 我有一个在C#下设计的漂亮的类库(DLL)。现在我需要 在VC ++项目中使用该库中的一个类(VS 2005)。 然而,我很难找到制作的可能性我的VC ++代码 查看该类的声明。在C#下没有头文件, 没有LIB链接到当前项目 - 仅DLL。我可以在我的项目中加载这个DLL ,可以卸载它,但我不知道如何声明一个类 实例... ''使用命名空间''没有帮助 - 编译器状态..没有这样的 名称空间...... 任何指导提示将受到高度赞赏。 Victor
Hi everybody ! I have a beautiful class library (DLL) designed under C#. Now I need to use a class from that library in a VC++ project (VS 2005). However, I desperately fail to find a possibility to make my VC++ code see the declaration of the class. There are no header files under C#, no LIB to link to the current project - solely DLL. I can load this DLL in my project, can unload it, but I do not know how to declare a class instance... ''using namespace'' does not help - compiler states "..no such namespace"... Any directing hint would be highly appreciated. Victor
推荐答案嗨Victor! 我有一个在C#下设计的漂亮的类库(DLL)。现在我需要在VC ++项目中使用该库中的类(VS 2005)。 I have a beautiful class library (DLL) designed under C#. Now I need to use a class from that library in a VC++ project (VS 2005).
请参阅:演练:创建和使用托管程序集 msdn2.microsoft/en -us / library / ms235638.aspx 请参阅:如何:在Visual Studio中添加或删除引用 msdn2.microsoft/en-us/library/wkze6zky.aspx (项目|参考文献......) - 问候 Jochen 我关于Win32和.NET的博客 blog.kalmbachnet.de/
See: Walkthrough: Creating and Using a Managed Assembly msdn2.microsoft/en-us/library/ms235638.aspx See: How to: Add or Remove References in Visual Studio msdn2.microsoft/en-us/library/wkze6zky.aspx (Project|References...) -- Greetings Jochen My blog about Win32 and .NET blog.kalmbachnet.de/
Jochen, 我必须道歉,但我没有找到你提供的链接中的东西是怎么回事我的问题...你知道,我是.NET的新手,所以 你会给我一些更多的评论,如果你愿意... 我有一个完全开发的类库在C#中,包含一个复杂的 类定义,引用许多其他来源。在编译这个 项目时,我只得到一个DLL,分别是调试或发布版本。 此外,我在VC ++中有一个相当高级的项目,使用MFC和 已经有很多不同的东西了。在这个项目中,我需要一个类,在上面提到的C#DLL中定义了。我的问题是:如何教我的VC ++ 关于在C#中创建的DLL中是否存在类定义? 我可以出色地使用这个类在另一个C#项目中。我可以使用在C ++中开发的DLL中指定的其他 类定义,因为我有他们的头文件。 和你指出的所有链接 - 据我所知 - 解释 如何在一种语言中做事。我似乎没有问题 这样...... 也许,我根本不明白任何正确的方法? 请问你帮我什么? Victor Jochen, I must apologize, but I do not find how the stuff from the links you provided pertains my problem... You know, I am quite new to .NET, so would you give me some more comments, if you please... I have a Class Library completely developed in C#, containig a complex definition of a class referring many other sources. On compiling this project I get only a DLL, respectively debug or release version. Further, I have a rather advanced project in VC++, using MFC and doing already many different things. In this project I need a class, defined in the mentioned C# DLL. The question of mine is : HOW to teach my VC++ about existence of the class definition in the DLL created in C# ? I can brilliantly use this class in another C# project. I can use other class definitions specified in DLL''s that have been developed in C++, because I have their header files. And all the links you pointed me to - as far as I understand - explain how to do things WITHIN ONE LANGUAGE. I do not seem to have problems like this... Maybe, I simply do not understand anything a proper way ? Will you help me any furhter, please ? Victor
你好Victor! 在编译这个项目时,我只得到一个DLL,分别是调试或发布版本。 是的。 如何教我的VC ++ 在C#中创建的DLL中是否存在类定义? 1st:你需要启用C ++ / CLI通过/ clr编译开关 (项目|设置|常规|公共语言运行时支持:/ clr) 您指出的所有链接 - 据我了解 - 解释<如何在一种语言中做事。我似乎没有问题这样...... On compiling this project I get only a DLL, respectively debug or release version. Yes. HOW to teach my VC++ about existence of the class definition in the DLL created in C# ? 1st: You need to enabled "C++/CLI" via the "/clr" compiler switch (Project|Settings|General|Common Language Runtime Support: /clr) And all the links you pointed me to - as far as I understand - explain how to do things WITHIN ONE LANGUAGE. I do not seem to have problems like this...
在.NET中你可以使用任何支持.NET的语言的DLL(程序集) (VB,C ++ / CLI,C#,...) 如果您启用了/ clr切换,然后你可以添加一个引用到你的DLL的! (项目|公共属性|参考资料)。 - - 问候 Jochen 我关于Win32和.NET的博客 blog.kalmbachnet.de/
更多推荐
C ++项目中的C#类库
发布评论