managed-c++

export function with clr parameters from dll?

旧街凉风 提交于 2019-12-02 00:28:44
I've got a legacy managed c++ dll, and I need to call some function which is returning a managed type. For dllexports without managed types, this is easy, I just define my static c(++) function in a header like this: extern "C" { __declspec(dllexport) int __cdecl InitSystem(); } But now the static c(++) function should return a managed type, and here I got a problem. If I try (for example): extern "C" { __declspec(dllexport) System::Collections::Generic::List<System::String^>^ __cdecl InitSystem(); } I get a compiler error (function definition needs __clrcall signature). Since the DLL is not

Will Windows 8 Metro support managed c++/cli

与世无争的帅哥 提交于 2019-12-01 19:18:05
I can't seem to find an answer to this question anywhere, but will metro support managed c++ ?? Right now in Visual Studios 2012 RC it does not (in Metro only). I have some frameworks written in c++/cli and wanted to port them to Metro. I know c++/cx is similar, but my c++/cli objects derive from ones written in C# and it would suck to have to rewrite that part of my system (but ok if I do, I just need to know where to go from here). If there are plans to support it when Windows 8 actually comes out, I can wait. Or if not I would like to know now so I can get to work on porting. C++/CLI is not

Are there any tools for converting Managed C++ to C++/CLI? [closed]

雨燕双飞 提交于 2019-12-01 17:02:39
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . We have an old project written using Managed C++ syntax. I would like to propose to the team a reasonably pain-free (I don't mind some level of human interaction, I think I'm realistic in my expectations that we'll still have to do some work by hand) method of updating the existing code to C++/CLI syntax so that

how to unload managed c++ dll?

你离开我真会死。 提交于 2019-12-01 13:48:43
A.dll is a native c++ dll, B.dll is a managed c++ dll. A.dll depends on B.dll, so when load A.dll, B.dll is loaded automatically, but after A.dll is unloaded, B.dll is still loaded. Only A.dll depends on B.dll, why B.dll can't be unloaded? How to unload the managed c++ dll? I'm using vs2010. Thanks You cannot unload a managed assembly once it is loaded by the CLR. The only way is to kill the AppDomain. 来源: https://stackoverflow.com/questions/7697621/how-to-unload-managed-c-dll

Whats the diffrence between an array<Byte>^ and a byte*?

China☆狼群 提交于 2019-12-01 12:33:15
And is it possible to cast the array< Byte>^ to an byte*? how would the below code need to changed to return a byte*? array<Byte>^ StrToByteArray(System::String^ unicodeString) { UTF8Encoding^ utf8 = gcnew UTF8Encoding; array<Byte>^ encodedBytes = utf8->GetBytes( unicodeString ); return encodedBytes; } array^ is a handle to an object in the managed heap, byte* is a pointer to an unmanaged byte. You cannot cast between them, but it is possible to fix the managed array and obtain a pointer to the elements within it. EDIT in response to first comment: Here's a code sample taken from this page on

Whats the diffrence between an array<Byte>^ and a byte*?

无人久伴 提交于 2019-12-01 10:47:46
问题 And is it possible to cast the array< Byte>^ to an byte*? how would the below code need to changed to return a byte*? array<Byte>^ StrToByteArray(System::String^ unicodeString) { UTF8Encoding^ utf8 = gcnew UTF8Encoding; array<Byte>^ encodedBytes = utf8->GetBytes( unicodeString ); return encodedBytes; } 回答1: array^ is a handle to an object in the managed heap, byte* is a pointer to an unmanaged byte. You cannot cast between them, but it is possible to fix the managed array and obtain a pointer

How do you dispose of an IDisposable in Managed C++

半城伤御伤魂 提交于 2019-12-01 02:52:12
I'm trying to Dispose of an IDisposable object(FileStream^ fs) in managed C++ (.Net 2.0) and am getting the error 'Dispose' : is not a member of 'System::IO::FileStream' It says that I should invoke the destructor instead. Will calling fs->~FileStream(); call the dispose method on the FileStream object? Why can't I call Dispose? The correct pattern is to just delete the object: delete fs; This will be translated into a call to Dispose() See this post for some of the details of what is going on under the hood. The advantage of this idiom is that it allows you to write: { FileStream fs(...) ...

Array initialization in Managed C++

巧了我就是萌 提交于 2019-12-01 01:45:49
问题 I wish to declare and initialize a 1D managed array of items. If it was C# code, I would write it like this: VdbMethodInfo[] methods = new VdbMethodInfo[] { new VdbMethodInfo("Method1"), new VdbMethodInfo("Method2") }; I am trying to write (well, actually, I'm writing a program generate) the same thing in managed C++... So far I have: typedef array<VdbMethodInfo^, 1> MethodArray; // How do I avoid pre-declaring the size of the array up front? MethodArray^ methods = gcnew MethodArray(2);

Loading Mixed-Mode C++/CLI .dll (and dependencies) dynamically from unmanaged c++

强颜欢笑 提交于 2019-11-30 15:03:26
I have a managed C++ assembly I'm loading dynamically in an unmanaged c++ application through a standard LoadLibrary() call. The managed C++ assembly has dependencies on several more managed (C#) assemblies. Everything worked fine until I moved all the managed assemblies to a subdirectory of the unmananged application. To illustrate: Managed C++ .dll (MyCoolDll.dll) Dependent on DotNetDll1.dll Dependent on DotNetDll2.dll Unmanaged C++ app (MyCoolApp.exe) Loads MyCoolDll.dll via LoadLibrary("MyCoolDll.dll") This worked fine, until I moved MyCoolDll.dll, DotNetDll1.dll & DotNetDll2.dll to

what is the C++/CLI syntax to subscribe for events?

倾然丶 夕夏残阳落幕 提交于 2019-11-30 09:14:59
问题 I'm updating some old Managed C++ code with lines like this: instanceOfEventSource->add_OnMyEvent( new EventSource::MyEventHandlerDelegate(this, MyEventHandlerMethod) ); where EventSource is the class that publishes events instanceOfEventSource is an instance of that class EventSource::MyEventHandlerDelegate is the delegate type for the event MyEventHandlerMethod is a (non-static) method within the current class (of which "this" is an instance) with the signature matching EventSource: