unmanaged

Is there a tool that generates P/Invoke signatures for arbitrary unmanaged DLL?

你。 提交于 2019-11-28 17:00:25
I stumbled upon a tool that generates P/Invoke signatures for Microsoft's own unmanaged DLLs: PInvoke Interop Assistant Is there a similar tool that will generate P/Invoke signatures for third-party unmanaged DLLs? Alternately, any way to feed a third-party DLL to PInvoke Interop Assistant EDIT: Actual issue I am trying to resolve Google quickly found http://www.pinvoker.com/ (Compatiblity listed as VS2005, 2008, and 2010; it doesn't seem to have been updated to work with newer versions) Microsoft's C++/CLI compiler can also do this, if you use /clr:safe and #include the header file, it will

Marshaling – what is it and why do we need it?

北城余情 提交于 2019-11-28 15:27:06
What is marshalling and why do we need it? I find it hard to believe that I cannot send an int over the wire from C# to C and have to marshall it. Why can't C# just send the 32 bits over with a starting and terminating signal, telling C code that it has received an int ? If there are any good tutorials or sites about why we need marshalling and how to use it, that would be great. Because different languages and environments have different calling conventions, different layout conventions, different sizes of primitives (cf. char in C# and char in C), different object creation/destruction

Detecting memory leak in mixed environment(Managed-Unmanaged)

∥☆過路亽.° 提交于 2019-11-28 14:32:53
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 page having just a frame. But still the leak happens!! Would some one please help me what could cause

Howto call an unmanaged C++ function with a std::vector as parameter from C#?

拟墨画扇 提交于 2019-11-28 14:16:56
I have a C# front end and a C++ backend for performance reasons. Now I would like to call a C++ function like for example: void findNeighbors(Point p, std::vector<Point> &neighbors, double maxDist); What I'd like to have is a C# wrapper function like: List<Point> FindNeigbors(Point p, double maxDist); I could pass a flat array like Point[] to the unmanaged C++ dll, but the problem is, that I don't know how much memory to allocate, because I don't know the number of elements the function will return... Is there an elegant way to handle this without having troubles with memory leaks? Thanks for

How do I find out if a .NET assembly contains unmanaged code?

徘徊边缘 提交于 2019-11-28 12:06:17
.NET assemblies that contain a mixture of managed and unmanaged code cannot be ILMerged with other assemblies. How can I verify if a given .NET assembly contains purely managed code, or a mix of managed and unmanaged code? Run the PEVerify tool against your assembly. PEVerify.exe is installed along with Visual Studio, e.g. this one comes with Visual Studio 2012: C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\PEVerify.exe As suggested by nobugz, an easier way to see the CLR Flags is using the corflags utility, which is part of the .NET 2.0 SDK. If no options are

How can I convert an unmanaged IntPtr type to a c# string?

白昼怎懂夜的黑 提交于 2019-11-28 11:56:40
I'm new to C# (from a native C++ background) and I'm trying to write a little UI to print windows broadcast messages among other things. I've overridden the default WndProc message loop in my C# program like so: [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")] protected override void WndProc(ref Message m) { // Listen for operating system broadcasts. switch (m.Msg) { case WM_SETTINGCHANGE: this.richTextLog.Text += "WM_SETTINGCHANGE - lParam=" + m.LParam.ToString() + "\n"; break; } base.WndProc(ref m); } What I'd like to know, is

Windows Azure not finding DLL of C++/CLI project

筅森魡賤 提交于 2019-11-28 11:45:11
I have a C++/CLI project that wraps around an unmanaged C compression library, and this project is referenced by an MVC3 project that calls the C++ Compress function. Everything works fine locally, but when I publish the solution to the Azure cloud, I get an error saying it could not find the module/dll: Could not load file or assembly 'LZGEncoder.DLL' or one of its dependencies. The specified module could not be found. Why can't it find the DLL file? is it going to the wrong place or being compiled at all? Is there any way I can check? Thanks! The problem was that the Visual C++ 2010 Runtime

vshost32.exe crash when calling unmanaged DLL

隐身守侯 提交于 2019-11-28 10:31:01
I'm using a VS 2005 app to interface against an unmanaged (Fortran) DLL. When I run the compiled executable straight from the command line, everything is fine - the DLL can be accessed, and I can work with the functions in the DLL. Unfortunately, when I launch the app from VS 2005, I get a popup stating "vshost32.exe has stopped working" and no useful debugging information. Has anyone experienced this behavior, or know why this might be occuring? I can't figure out why it would run fine when launched stand-alone, but not via vshost32. (One last note: I am using .local files to force registered

Swift UnsafeMutablePointer<Unmanaged<CFString>?> allocation and print

放肆的年华 提交于 2019-11-28 09:26:58
I'm new to swift and I have some difficulties to deal with pointers of unmanaged CFString (or NSString). I'm working on a CoreMIDI project that implies usage of UnsafeMutablePointer?> as you can see in this function : func MIDIObjectGetStringProperty(_ obj: MIDIObjectRef, _ propertyID: CFString!, _ str: UnsafeMutablePointer<Unmanaged<CFString>?>) -> OSStatus My problem is that I want to allocate a buffer to receive the content of the property (_str) then call the function above, and finally print the content in the console by using println. At the moment I wrote this : // Get the first midi

Passing char pointer from C# to c++ function

自闭症网瘾萝莉.ら 提交于 2019-11-28 08:59:27
问题 I am stuck in c# implementation side, as I am pretty new to it. The thing is, I want to pass a 'pointer'(having memory) from c# code so that My c++ application can copy pchListSoftwares buffer to pchInstalledSoftwares. I am not able to figure out how to pass pointer from c# side. native c++ code(MyNativeC++DLL.dll) void GetInstalledSoftwares(char* pchInstalledSoftwares){ char* pchListSoftwares = NULL; ..... ..... pchListSoftwares = (char*) malloc(255); /* code to fill pchListSoftwares buffer*