unmanaged

C++/CLI: wrapping the same unmanaged object in multiple managed objects

老子叫甜甜 提交于 2020-01-16 08:45:10
问题 I am developing a library which has two layers, unmanaged (C++) and managed (C++/CLI). The unmanaged layer contains the logics and the computation algorithms, while the managed layer provides interface and visualisation to a .NET-based host application. A class in the managed layer wraps its class counterpart in the unmanaged layer, e.g. ManagedA wraps UnmanagedA and ManagedB wraps UnmanagedB. Classes in the unmanaged layer have query methods, suppose UnmanagedA::B() returns an instance of

Memory usage of DotNET app

强颜欢笑 提交于 2020-01-15 09:39:10
问题 My application (DotNET) runs as a plug-in inside a C++ standalone app that exposes a C++/CLI SDK. It is very easy for my users to generate large amounts of data and I'd like to offer an abort option if the memory consumption of my plug-in + the base application reaches -say- 90% of the legal maximum. How can I measure the total memory consumption (ideally for both the managed and unmanaged code) and how do I know how much memory windows allows for the current application? 回答1: The Process

Calling C++ function using DllImport

冷暖自知 提交于 2020-01-15 03:32:05
问题 This one is basic, how do I call the function SubscribeNewsFeed in the following from a C# DllImport? class LogAppender : public L_Append { public: LogAppender() : outfile("TestLog.txt", std::ios::trunc | std::ios::out) , feedSubscribed(false) { outfile.setf(0, std::ios::floatfield); outfile.precision(4); } void SubscribeNewsFeed() { someOtherCalls(); } }; I'm unable to figure out how to include the class name when using the DllImport in my C# program here: class Program { [DllImport(

Cannot Update WPF GUI While Using Unmanaged Libraries In Background

自作多情 提交于 2020-01-14 14:07:24
问题 I've enocountered a problem while trying to use Emgu to capture images from a webcam. To do this task, Emgu uses unmanaged opencv libraries. So the problem is that I can't update my GUI (WPF Image control) from System.Timers.Timer Elapsed event. I know it's running in different thread, but hey, that's why I'm using a Dispatcher. It's the first time I can't do it with Dispatcher. Getting InvalidOperationException with "The calling thread cannot access this object because a different thread

How to copy a array of unmanaged memory into the same unmanaged memory

耗尽温柔 提交于 2020-01-14 13:47:06
问题 I reserved memory 10 items of 128 bytes IntPtr dst = Marshal.AllocHGlobal (10 * 128); IntPtr src1 = Marshal.AllocHGlobal (128); // .... init scr1 from DLL IntPtr src2 = Marshal.AllocHGlobal (128); // .... init scr2 from DLL I need to copy the 128 bytes elements of src1 and src2 to dst at the specified offset. Marshal.Copy not suitable for such purposes. Since the src and dst in unmanaged memory area. 回答1: The Window's API function memcopy should do the trick. [DllImport("msvcrt.dll",

Asp.net calling C# layer calling Managed C++ calling Native C++

谁都会走 提交于 2020-01-14 13:16:10
问题 My project structure is as follow: ASP.NET calling C# layer calling Managed C++ calling Native C++ (i'm trying to avoid using interop so this is why the managed c++ layer) I wrote unit test that test the C# layer and it works fine. When I try to run the asp.net page i'm getting: "Could not load file or assembly..." error. I figured out that when i copy paste the Native C++ dll to "Temporary ASP.NET Files" (to the corresponding folder) the site works. It seems that the Managed C++ code can

System Wide Shell Hook from .NET using Unmanaged DLL

余生颓废 提交于 2020-01-14 05:23:40
问题 I have used the code supplied in the following CodeProject article in the past with success, but it only seems to partially work on Vista/7 (I'm guessing because of UAC). It works for the current thread, but it doesn't pick up system wide activity. I've tried adding requireAdministrator in the manifests and signing both the unmanaged and managed assemblies, and that doesn't appear to help. Using Window Messages to Implement Global System Hooks in C# My main goal is to use SetWindowsHookEx to

Reference an unmanaged C++ DLL from Managed C++

隐身守侯 提交于 2020-01-13 06:23:06
问题 This question follows from my previous question: Create DLL from unmanaged C++, but you would not have to read it to understand this new question. I now have a DLL that contains unmanaged C++ code consisting of a few functions, of which I only export one for outside use. Next, I need to use this DLL in a Managed C++ project (built with Common Language Runtime support). So far, I have added a reference to the existing unmanaged project's header file by setting the Additional Include

Where to place dlls for unmanaged libraries?

纵饮孤独 提交于 2020-01-12 04:03:51
问题 I am trying to create a Nuget package for a library that depends on ghostscript and therefore references gsdll32.dll - an unmanaged library. I can't just included that a standard dll reference. Where do I put this in the nuget directory structure? 回答1: Add a build folder to the package and, if the package for example has the id MyPackage , add a MSBuild target file called MyPackage.targets to this folder. It is important that the .targets file has the same name as the .nuspec file. In the

Where does DLLImport look for unmanaged DLLs?

你离开我真会死。 提交于 2020-01-10 18:54:13
问题 A quick question: When declaring the DLLImport Attribute in .Net, where does the runtime look to resolve that DLL dependency? Would I have to dump the DLL and all of its dependencies in the bin folder? 回答1: I think it is working like LoadLibrary. Maybe Windows path searching in LoadLibrary with manifest will be helpfull. Edit Dynamic-Link Library Search Order is probably what you want. 回答2: Generally, you'd expect it to look at whatever's defined in the user's Path. To find out what this