从非托管代码调用托管C ++ / CLI [英] Invoking Managed C++/CLI from Unmanaged Code
问题描述
大家好,
1.我是Managed C ++的新手,在我的程序中,基于C ++,如果我需要转换到托管C ++并使用等效结构。
例如,
< b> System :: String ^ ptr = gcnew(C:\Dir1 \abc.txt);
// SomeClass ObjSomeClass应使用<< ; PTR>>在MC ++中
并在类someClass中输入上面的ptr
你能告诉我使用托管C ++的方法,
基本上,上述路径应该可用于托管C ++中的某些类,
2.除了在非托管代码中包含以下内容以获取自动完成/是否有任何先决条件/ intellisense能够调用托管代码(C ++ / CLI)
#includeStdafx.h
.....
使用< mscorlib.dll>
使用System;
使用System :: EnterpriseServices ::内部;
....
使用System :: EnterpriseServices :: Internal的项目属性添加引用将.NET Framework设置为3.5及以上
,编译器切换设置也使用/ CLR。
尽管有上述内容,仍然无法调用托管代码( C ++ / CLI)请告诉我解决的过程同样的。
解决上述问题的任何帮助都会非常明显。
问候,
VishalK_90
Hi All,
1. I am new to Managed C++, In my program, based on C++, In case I need to make a transition to Managed C++ and use the equivalent constructs.
Eg.,
System::String ^ ptr = gcnew ("C:\Dir1\abc.txt");
// SomeClass ObjSomeClass should consume the <<ptr>> in MC++
and input the above ptr in the Class someClass
Could you let me know the approach by using the Managed C++,
Basically the above path should be available to the someclass in managed C++,
2. Are there any prerequisites other than including the following in Unmanaged Code to obtain autocompletion/intellisense to able to invoke Managed Code(C++/CLI)
#include "Stdafx.h"
.....
using <mscorlib.dll>
using System;
using System::EnterpriseServices::Internal;
....
Adding References using the project properties for System::EnterpriseServices::Internal and also setting the .NET Framework to 3.5 and above
also, Compiler Switch Settings to using /CLR.
despite of the above inclusions, still I am unable to invoke Managed Code(C++/CLI) Please let me know the process to resolve the same.
any help in resolving the above would be much appreciable.
Regards,
VishalK_90
推荐答案
用于C ++ / CLI的Intellisense不起作用VS2010。我相信它在VS2012中工作,所以如果可以,你可能想要升级到它。
Intellisense for C++/CLI does not work on VS2010. I believe it is working in VS2012 though, so you might want to upgrade to that if you can.
这篇关于从非托管代码调用托管C ++ / CLI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!