managed

Using WinDbg/SOS to debug managed->native callstack. I get “Failed to request ThreadStore”

对着背影说爱祢 提交于 2019-12-18 09:23:34
问题 MyManagedFunc in managed.exe calls into MyUnmanagedFunc() in unmanaged.dll. I produce a minidump in unmanaged.dll using Win32. SetUnhandledExceptionFilter. I can see MyUnmanagedFunc in the callstack, but nothing usefull in the managed side. I'm supposed to be able to use WinDbg and SOS.dll to see the managed calls, right? Below is my WinDbg session. What am I doing wrong? Executable search path is: Windows XP Version 2600 (Service Pack 3) MP (4 procs) Free x86 compatible Product: WinNt, suite

How can I send a managed object to native function to use it?

馋奶兔 提交于 2019-12-18 04:23:34
问题 How can I send a managed object to native function to use it? void managed_function() { Object^ obj = gcnew Object(); void* ptr = obj ??? // How to convert Managed object to void*? unmanaged_function(ptr); } // The parameter type should be void* and I can not change the type. // This function is native but it uses managed object. Because type of ptr could not be // Object^ I called it "Unmanaged Function". void unmanaged_function(void* ptr) { Object^ obj = ptr ??? // How to convert void* to

Detecting memory leak in mixed environment(Managed-Unmanaged)

百般思念 提交于 2019-12-17 21:14:47
问题 I've an application written in VC++ MFC 6.0. Recently got upgraded to .NET 3.5 by compiling in vs2008 and added some WPF applications to it by using managed and unmanaged environment. Basically hosting WPF on win32 window. If I just open a WPF app window, memory keeps going up like 1KB/10 secs. I've tried using .NET Memory profiler & Ants memory profiler. But both are not helping me in detecting the leaks!! I've removed all the WPF controls from the hosted WPF application. It just contains a

Is it possible to share an enum declaration between C# and unmanaged C++?

感情迁移 提交于 2019-12-17 15:44:19
问题 Is there a way to share an enum definition between native (unmanaged) C++ and (managed) C#? I have the following enum used in completely unmanaged code: enum MyEnum { myVal1, myVal2 }; Our application sometimes uses a managed component. That C# component gets the enum item values as ints via a managed C++ interop dll (from the native dll). (The interop dll only loads if the C# component is needed.) The C# component has duplicated the enum definition: public enum MyEnum { myVal1, myVal2 }; Is

C++/CLI: make public for template type

那年仲夏 提交于 2019-12-14 02:21:49
问题 AFAIK #pragma make_public supports only native non-template types. But, is there some other way to make template type as public? 回答1: No. But read here for some workarounds: Best workaround for compiler error C2158: make_public does not support native template types http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/b43cca63-b0bf-451e-b8fe-74e9c618b8c4/ 回答2: Templates don't have external linkage. Not in native C++, not in C++/CLI either. You solve it the same way, put them in a

How can I pass an empty string buffer that can be written to from native to c#?

柔情痞子 提交于 2019-12-14 02:18:52
问题 I'm trying to get a string from my managed code into my unmanaged code: unmanaged dll: typedef int (__stdcall * GetNameFromDictionaryCallback)(ULONGLONG id, WCHAR * name); declspec(dllexport) void __stdcall UnmanagedSetNameLookupCallback(GetNameFromDictionaryCallback fn) { GetNameFromDictionaryCallback GetNameFromDictionary = fn; WCHAR * value = new WCHAR[256]; ULONGLONG key = 0x250000000DA44785; GetNameFromDictionary(key, value); // reverse P/Invoke call to C# function wprintf_s("%ls", value

members of class being overwritten when new instance created c++/cli

核能气质少年 提交于 2019-12-13 23:54:32
问题 I have tried to implement the following: 1) Create a class that contains managed arrays 2) Create three instances of this class 3) Fill those arrays from three different data files. 4) Perform an analysis of this data I have been able to compile code that performs task numbers one and two, however when I fill the arrays of the subsequent instances they seem to overwrite the data of the previous ones. I have tried to use a structure instead of a class. I have tried to use native arrays instead

Managed and unmanaged code error C3699

有些话、适合烂在心里 提交于 2019-12-13 07:23:52
问题 I am working on a game which uses C# and C++. Classes for models are written in C# and levels structure is stored in XML files. When I want read it in C++ and want to build project I have this strange error and I don't where to find some bugs. Error 1 error C3699: '*' : cannot use this indirection on type 'Cadet::XMLReader::Models::Obstacle' C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xmemory0 527 1 Cadet.Game These kind of errors are in xmemory0 and list files? what they

How to execute c++ function in a parallel thread under WinRT?

こ雲淡風輕ζ 提交于 2019-12-12 18:32:59
问题 I have a C++ code which uses _beginthreadex() Windows method to execute a function in a thread. Now I want to port it to WinRT component to include it in windows phone app. But windows phone does't support _beginthreadex(). How do I do it? my function is: bool doesWordAppearInDictionarry(char* word); I have 4 cores on my computer so I want to execute 4 copies of this function in parallel (searching for 4 different words in the dictionary simultaneously). I read (here) and (here) about Windows

Calling a C# function from unmanaged c++ (via a managed wrapper)

左心房为你撑大大i 提交于 2019-12-12 12:32:27
问题 I have C++ source & headers for a set of libraries which I need to call from a C# application. I've created a managed C++ wrapper around the functions I need and am able to call them from C# marshalling the data backwards and forwards. Now the hard part.. My unmanaged C++ library generates status messages as it runs and I'd like to be able to display these from the calling C# application. My current thinking goes like this: I'd like the unmanaged C++ library code to call a function in my C#