managed-c++

Managed C++ wrappers for legacy C++ libraries

我的梦境 提交于 2019-12-17 23:44:31
问题 We're looking at writing a .Net-callable wrapper for some legacy C++ libraries using managed C++. It all looks pretty easy. Is there anything we need to watch out for? 回答1: I found it generally quite easy to wrap some existing C++ libraries in C++/CLI and encountered comparatively few pitfalls. The ones I can remember were: Mixing unmanaged C++ code and C++/CLI code in the same executable/DLL is a really bad idea. I've run into problems with competing memory managers at shutdown time that way

Could not load file or assembly '***.dll' or one of its dependencies

梦想的初衷 提交于 2019-12-17 17:56:06
问题 I have this dll that I created a long time ago and use to connect to the db of a specific software that I develop for. I have had no issues for well over 4 years and countless applications with this dll. Trying to deploy my latest creation, I get the following error: System.IO.FileNotFoundException: Could not load file or assembly '***.dll' or one of its dependencies. The specified module could not be found. So, for every dll I ever wrote, I always made a simple forms application to test that

EEFileLoadException when using C# classes in C++(win32 app)

风流意气都作罢 提交于 2019-12-17 15:54:38
问题 For deployment reasons, I am trying to use IJW to wrap a C# assembly in C++ instead of using a COM Callable Wrapper. I've done it on other projects, but on this one, I am getting an EEFileLoadException. Any help would be appreciated! Managed C++ wrapper code (this is in a DLL): extern "C" __declspec(dllexport) IMyObject* CreateMyObject(void) { //this class references c# in the constructor return new CMyWrapper( ); } extern "C" __declspec(dllexport) void DeleteMyObject(IMyObject* pConfigFile)

EEFileLoadException when using C# classes in C++(win32 app)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 15:53:56
问题 For deployment reasons, I am trying to use IJW to wrap a C# assembly in C++ instead of using a COM Callable Wrapper. I've done it on other projects, but on this one, I am getting an EEFileLoadException. Any help would be appreciated! Managed C++ wrapper code (this is in a DLL): extern "C" __declspec(dllexport) IMyObject* CreateMyObject(void) { //this class references c# in the constructor return new CMyWrapper( ); } extern "C" __declspec(dllexport) void DeleteMyObject(IMyObject* pConfigFile)

How do I call C++/CLI from C#?

你说的曾经没有我的故事 提交于 2019-12-17 02:54:12
问题 I have a class implemented in C++ that's responsible for the arithmetic computation of the program, and an interface using WPF. I process the input with C# but then how can I use my C++ class? I've seen some comments about making a managed C++ wrapper class to interact with it, but I don't know where to start. Nor do I know how I'd go to compile it along with all the other code. I can't really find a tutorial on this, and the stuff google shows on managed C++ doesn't really seem helpful.

A procedure imported by {dll} could not be loaded

我只是一个虾纸丫 提交于 2019-12-13 06:09:28
问题 I have several Unmanaged C++ written lib files which I need to link to Managed C++ dll. Then I need to invoke functions of this Managed C++ from C# application. First step is OK - Managed C++ dll is created, I can see with ildasm that it exports functions I need. However when I try to call this function from my C#-written test app it says: An unhandled exception of type 'System.IO.FileLoadException' occurred in Unknown Module. A procedure imported by {MyManagedCPP.dll} could not be loaded.

Managed C++ ^ (handle) --> What is it and how does it relate to references and pointers

久未见 提交于 2019-12-13 02:01:27
问题 What is the difference between a handle to an object in Managed C++ such as: System::String^ str = gcnew System::String(); and the ordinary C++ pointers? Also how do they relate to references we have in C#? 回答1: You are not talking about (the older) Managed C++, but about C++/CLI, right? In C#, your code is equivalent to System.String str=new System.String(); In C++/CLI, a handle to an object is just the same as a reference in C# - you have reference counting, garbage collector etc. Ordinary

Exporting c++ function, declared in vb6, getting “remote procedure call failed” runtime error

心已入冬 提交于 2019-12-12 03:02:42
问题 I have a dll written in C++ that is being exported like so: extern "C" { extern _declspec(dllexport) (VOID) Merge(LPCSTR szFileName, LPCSTR szMergeString, DWORD dwAlignment, BOOL fRepeat); } That function is defined elsewhere as: extern _declspec(dllexport) (VOID) Merge(LPCSTR szFileName, LPCSTR szMergeString, DWORD dwAlignment, BOOL fRepeat) { Tools::Merge(gcnew String(szFileName), gcnew String(szMergeString), dwAlignment, fRepeat == TRUE); } In my vb6 dll, I have declared the remote call

How to GetGuiResources for all system processes?

家住魔仙堡 提交于 2019-12-12 01:35:12
问题 I need to measure all used GDI objects in a Windows xp system. I found a GetGuiResources(__in HANDLE hProcess, __in DWORD uiFlags) method (with the GR_GDIOBJECTS flag). I call it for the process which I get from the method GetCurrentProcess() defined in WinBase.h. I don't know how to call it for other system processes, which I get by System::Diagnostics::Process::GetProcesses(), because that function returns an array of Process pointers, and GetGuiResources takes a HANDLE. Does anybody know a

Writing C# managed code in native C++

狂风中的少年 提交于 2019-12-11 07:31:02
问题 I am developing a managed lib (using Microsoft Web Services) and I am including it into a c++ project. The project doesn't use /clr option, so when I include my library's header file VS2005 show me an error saying I have to use /clr option. Doing this I have a incompatibility with /EHs command line option (error D8016), but changing from EHs to no exception handling not solving problem and keep showing me same error . Any suggestion is welcome. Thank you in advance. 回答1: If you have unmanaged