managed

Managing destructors of managed (C#) and unmanaged (C++) objects

本秂侑毒 提交于 2019-12-01 06:35:43
I have a managed object in a c# dll that maintains an anonymous integer handle to an unmanaged object in a c++ dll. Inside the c++ dll, the anonymous integer is used in an std::map to retrieve an unmanaged c++ object. Through this mechanism, I can maintain a loose association between a managed and unmanaged object using an anonymous integer handle. In the finalize method (destructor) of the managed object I have a call into the unmanaged dll to delete the unmanaged object. All is well as the c# program runs, but I have a problem when the program exits. Becuase I have no control on the order of

Managing destructors of managed (C#) and unmanaged (C++) objects

眉间皱痕 提交于 2019-12-01 05:18:23
问题 I have a managed object in a c# dll that maintains an anonymous integer handle to an unmanaged object in a c++ dll. Inside the c++ dll, the anonymous integer is used in an std::map to retrieve an unmanaged c++ object. Through this mechanism, I can maintain a loose association between a managed and unmanaged object using an anonymous integer handle. In the finalize method (destructor) of the managed object I have a call into the unmanaged dll to delete the unmanaged object. All is well as the

How to get Visual Studios build system to understand unmanaged dependencies of managed dlls?

不问归期 提交于 2019-12-01 03:56:25
When building managed code Visual Studio correctly (and recursively) copies dlls of referenced managed projects to the output folder of the project being build. However, if one the of those references is a managed DLL that depends on unmanaged dlls then these unmanaged DLLs are not copied to the output folder, even though their corresponding projects in the same solution and are listed as dependencies of the managed DLL. I realize that this problem can be resolved by having all projects use the same output folder. We already do that for most projects, but we prefer to keep unit test output

How do I show Error Message using Managed Custom Actions with Windows Installer

坚强是说给别人听的谎言 提交于 2019-12-01 03:50:48
I am writing a managed custom action. I am using the DTF Framework from Windows Installer Xml to wrap the managed dll into a usable CA dll. The CA does what it is supposed to, but I am still having trouble with error handling: Dim record As New Record(1) ' Field 0 intentionally left blank ' Field 1 contains error number record(1) = 27533 session.Message(InstallMessage.Error, record) The above code produces the following text shown in the MSI log: MSI (c) (C4 ! C6) [13:15:08:749]: Product: TestMSI -- Error 27533. The case-sensitive passwords do not match. The error number refers to the code

How to get Visual Studios build system to understand unmanaged dependencies of managed dlls?

情到浓时终转凉″ 提交于 2019-12-01 00:18:09
问题 When building managed code Visual Studio correctly (and recursively) copies dlls of referenced managed projects to the output folder of the project being build. However, if one the of those references is a managed DLL that depends on unmanaged dlls then these unmanaged DLLs are not copied to the output folder, even though their corresponding projects in the same solution and are listed as dependencies of the managed DLL. I realize that this problem can be resolved by having all projects use

How do I call C++/CLI (.NET) DLLs from standard, unmanaged non-.NET applications?

蹲街弑〆低调 提交于 2019-11-30 19:19:15
In the unmanaged world, I was able to write a __declspec(dllexport) or, alternatively, use a .DEF file to expose a function to be able to call a DLL. (Because of name mangling in C++ for the __stdcall, I put aliases into the .DEF file so certain applications could re-use certain exported DLL functions.) Now, I am interested in being able to expose a single entry-point function from a .NET assembly, in unmanaged-fashion, but have it enter into .NET-style functions within the DLL. Is this possible, in a simple and straight-forward fashion? What I have is a third-party program that I have

What's the difference between a non-unmanaged type and a managed type?

谁都会走 提交于 2019-11-30 12:52:03
问题 When I wrote the following snippet for experimenting purposes, it raised the hover-error (see screenshot): Cannot declare pointer to non-unmanaged type 'dynamic' The snippet: dynamic* pointerToDynamic = &fields; While the code is clearly not allowed (you cannot take the address of a managed type), it raised with me the question: what is a non-unmanaged type and how is it different to a managed type? Or is it just Visual Studio trying to be funny? 回答1: There is a difference between unmanaged

Value Class in C++/CLI

余生颓废 提交于 2019-11-30 12:44:48
What are the benifits of using a value class in C++/CLI.Can the value class contain member functions? a value class is a ValueType - that means, whenever you assign it to another variable of the same type, the whole object gets copied into the other variable, leaving you with two separate copies. Examples of this are basic numeric data types like int , bool or double . ValueTypes are sealed, which means you cannot derive from them. A ref class is a reference type - if you assign it to another variable of the same type, you copy only a reference. So the two variables basically "point" to the

Is this DLL managed or unmanaged?

▼魔方 西西 提交于 2019-11-30 06:55:33
问题 I hold before you a DLL. Using only the Win32 SDK, can you tell me if this DLL is a .NET assembly? Why? Our application loads plugins in the form of DLLs. We are trying to extend the definition of these plugins to allow for .NET assemblies but the interface will be different and thus the loader will need to know if the DLL is managed or unmanaged before loading it. 回答1: You can check the PE header information for the information about what type of information is contained in the DLL. This

How do i prevent my code from being stolen?

时间秒杀一切 提交于 2019-11-30 06:20:49
问题 What happens exactly when I launch a .NET exe? I know that C# is compiled to IL code and I think the generated exe file just a launcher that starts the runtime and passes the IL code to it. But how? And how complex process is it? IL code is embedded in the exe. I think it can be executed from the memory without writing it to the disk while ordinary exe's are not (ok, yes but it is very complicated). My final aim is extracting the IL code and write my own encrypted launcher to prevent