mixed-mode

Mixed-mode C++/CLI app not shutting down CLR correctly

早过忘川 提交于 2019-12-01 10:30:54
问题 My mixed-mode MFC application is creating false memory leaks because the CRT doesn't have time to shut down before the MFC dll is shut down. I have a very simple little app that shows the problem: #include <windows.h> #include <iostream> struct LongTimeToDestroy { ~LongTimeToDestroy() { std::cout << "Will get called!" << std::endl; Sleep(3000); std::cout << "Won't get called!" << std::endl; } }; LongTimeToDestroy gJamsUpTheCRT; int main() { } Compile with cl.exe /clr test.cpp . When run, you

C++/CLI Wrapping a Function that Returns a std::shared_ptr

匆匆过客 提交于 2019-12-01 08:23:48
I'm currently wrapping a C++ class with C++/CLI for .NET interoperability following the standard process of holding a native pointer in a managed class. In one instance, I have a native class that has a function like: std::shared_ptr<BaseChannel> channelData(const int RunNumber); I have already begun creating a wrapper class for BaseChannel . However, if I pass the raw pointer to the constructor of the managed class, there are no guarantees on the lifetime of the object being pointed to by the managed class. I.e. the shared_ptr could go out of scope and the object will get deleted and the

Destruction of Native Objects with Static Storage Duration

给你一囗甜甜゛ 提交于 2019-11-30 13:39:53
问题 2012-12-09 Summary: In a normal mixed-mode application global native C++ destructors run as finalizers. It's not possible to change that behavior or the associated timeout. A mixed-mode assembly DLL runs C++ constructors/destructors during DLL load/unload - exactly as a native DLL. Hosting the CLR in a native executable using the COM interface allows both the deconstructors to behave as in a native DLL (the behavior I desire) and setting the timeout for finalizers (an added bonus). As far as

Fast capture stack trace on windows / 64-bit / mixed mode

最后都变了- 提交于 2019-11-30 09:20:31
Like most of you probably know there exists plenty of different mechanisms to walk stack traces, starting from windows api, and continuing further into depth of magical assembly world - let me list here some of links I've already studied. For of all let me mention that I want to have mechanism of memory leak analysis of mixed mode (managed and unmanaged) / 64-bit + AnyCPU application and from all windows api's CaptureStackBackTrace is most suitable for my needs, but as I have analyzed - it does not support managed code stack walking. But that function API is closest to what I need (Since it

Destruction of Native Objects with Static Storage Duration

徘徊边缘 提交于 2019-11-30 08:03:35
2012-12-09 Summary: In a normal mixed-mode application global native C++ destructors run as finalizers. It's not possible to change that behavior or the associated timeout. A mixed-mode assembly DLL runs C++ constructors/destructors during DLL load/unload - exactly as a native DLL. Hosting the CLR in a native executable using the COM interface allows both the deconstructors to behave as in a native DLL (the behavior I desire) and setting the timeout for finalizers (an added bonus). As far as I can tell the above applies to at least Visual Studio 2008, 2010 and 2012. (Only tested with .NET 4)

Mixed Mode Library and CRT Dependencies - HELP

本小妞迷上赌 提交于 2019-11-29 17:18:51
Alright, after doing a ton of research and trying almost every managed CPP Redist I can find as well as trying to copy my DLLs locally to the executing directory of the app I cannot figure out what dependencies i'm missing for this mixed mode library. Basically I have a large C# application and I'm trying to use a mixed mode library I made. On the development machine it works perfect (of course) but deployed when the library needs to be loaded for use it exceptions out because of missing CRT dependencies (I assume). I have used dependency walker to check all the DLLs referenced and ensured

Mixed mode assembly is built against version '2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime

强颜欢笑 提交于 2019-11-29 14:41:15
问题 I'm using Visual Studio 2012 and the .Net Framework 4.5 I have 2 Solutions: 1) WPF Application 2) Class library (dll) The Class Library contains 3 buttons and a control that has to be inside a WindosFormsHost control since it was made for WinForms. The only referenced assemblies outside of the .NET Framework ones are for the aforementioned winforms control and iTextSharp. The winforms control seems to be kinda old and when I put the reference in my dll I got the same error as the title but

unmanaged var as member of managed class c++

僤鯓⒐⒋嵵緔 提交于 2019-11-29 14:14:10
I'm novice in .net c++ and trying to create class looking like: public ref class Klient { public: Klient(){} // zmienne static DWORD klienty[41][2]; static int i = 1; static DWORD* pid; static HANDLE* handle; //funkcje }; but MSV says that: error C4368: cannot define 'klienty' as a member of managed 'Klient': mixed types are not supported What's wrong with this code? You can have .NET basic data types as members of your managed class (static int i), or pointers to anything unmanaged (DWORD* pid, HANDLE* handle), but you're not allowed to have an unmanaged object directly, and the array of

Resolve managed and native stack trace - which API to use?

微笑、不失礼 提交于 2019-11-29 11:21:25
This is continuation to my previous question - phase 2 so to say. First question was here: Fast capture stack trace on windows / 64-bit / mixed mode Now I have resolved a huge amount of stack traces and now wondering how to resolve symbol information of managed stack frames. For native C++ side it's relatively simple - First you specify which process from where to take symbols: HANDLE g_hProcess = GetCurrentProcess(); Where you can replace process in run-time using code snipet like this: g_hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, g_processId); b = (g_hProcess != NULL ); if( !b )

c++/cli DLL fails under Win 8.1

做~自己de王妃 提交于 2019-11-29 05:37:29
i have written a Win32/net DLL, it works fine under Win XP, Win7 and 8 but under Win 8.1 it fails. Dependency Walker says: API-MS-WIN-CORE-KERNEL32-PRIVATE-L1-1-1.DLL not found (user32.dll will call them) Google means, MS changed some System-DLLs in 8.1 (and ignored compatibility), so that many programs have the same problem. Full list with "file not found": API-MS-WIN-CORE-KERNEL32-PRIVATE-L1-1-1.DLL API-MS-WIN-CORE-PRIVATEPROFILE-L1-1-1.DLL MSVCR120.DLL API-MS-WIN-CORE-SHUTDOWN-L1-1-1.DLL API-MS-WIN-SERVICE-PRIVATE-L1-1-1.DLL EXT-MS-WIN-NTUSER-UICONTEXT-EXT-L1-1-0.DLL IESHIMS.DLL Does