unmanaged

Is it possible to catch an access violation exception in .NET??

Is there anything I can do to catch an AccessViolationException? It is being thrown by a unmanaged DLL that I don't control. ...

Handling a Struct native to C# in C++.

Here is my call in C cli::array<mercurial::fileItem>^ tmp = mercFlowCLR::merc::getFolderList(gcnew System::String(remotePath)); Here is my C# Structure: public struct fileItem { public string fileName; public bool isFolder; } My getFolderList is returning of type in C#: List<mercurial::fileItem> The C++ DL...

Managed to unmanaged code call causes access violation... sometimes

This code causes the following exception, sometimes: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt" private static TOKEN_GROUPS GetTokenGroups(IntPtr tokenHandle) { var groups = new TOKEN_GROUPS(); uint tokenInfoLength = 0; uint returnLength; var res = Ge...

Marshal.StructureToPtr crashes Visual Studio

I'm working on a custom debug engine and when I marshal my structure to a IntPtr Visual Studio crashes (the one being debugged not the debugger). My struct is little more than: public struct DocumentContext : IDebugDocumentContext2, IDebugCodeContext2 { private string _fileName; //.....Implementation of interfaces } My mar...

Calling managed code from unmanaged code in VS2010

Hi, I have an managed c# application that uses expression encoder 4 SDK, and thus requires .NET 4 and hence VS2010. I wish to startup and stop this application as an in process DLL. This article and demo on code project proved a very useful proof of principle http://www.codeproject.com/KB/mcpp/ijw_unmanaged.aspx The included demo wo...

What is the Difference in Managed and Unmanaged Code, Memory and Size?

After seeing and listening lot about Managed and Unmanaged Code , and knowing about the only difference is that Managed is about CLR and un-managed is out side of CLR, it makes me really curious to know in detail , what is it that all about Managed and Un-Managed Code,Memory and Size? How can a code I write in C# can be unmanaged while ...

How to convert IntPtr of HIMAGELIST to Bitmap/Image

I am trying to use an HIMAGELIST from an unmanaged dll which gives me the result as an IntPtr. Is there a way for me to turn this IntPtr into a Bitmap or an Image so I can use it for Winforms buttons, as in: myButton.Image = intPtrImage ...

I want to call a C# delegate from C++ unmanaged code. A parameterless delegate works fine , but a delegate with parameters crashed my program.

The Following is code of a function from a unmanged dll. It takes in a function pointer as argument and simply returns value returned by the called function. extern __declspec(dllexport) int _stdcall callDelegate(int (*pt2Func)()); extern __declspec(dllexport) int _stdcall callDelegate(int (*pt2Func)()) { int r = pt2Func(); re...

Can one prevent Microsoft Error Reporting for a single app?

We have an unmanaged C++ application that utilizes 3rd party APIs to read CAD files. On certain corrupted CAD files, the 3rd party library crashes and brings our EXE down with it. Because of this our main application is a separate EXE and in this way it does not get affected by the crash. Howevever, we end up with annoying Microsoft Erro...

How to access unmanaged data from C#

I have an unmanaged (C/C++) DLL which I need to call from a C# application. The DLL call needs to return data (from a C++ class that is created by the DLL) to the C# application. I have control over the DLL's exported function, so I can create a wrapper around the C++ class if necessary. I know how to access the DLL with p/Invoke, so ...

What exactly are unmanaged resources?

I want to know about unmanaged resources. Can anyone please give me a basic idea? ...

C# interop : handling pointer-array in unmanaged struct

I'm wrapping a few calls to the unmanaged Aubio library dll (Aubio.org), and I'm wondering what a good way is to deal with the Aubio samplebuffer. It's defined like this : // Buffer for real values struct _fvec_t { uint length; // length of buffer uint channels; // number of channels float **data; // data array of size [len...

Is a WPF application managed code only?

I want to use WPF in an app. I want to write it in C++. Does the application have to be managed? I know that I can mix managed with unmanaged. I'm wondering if I can have the whole application be unmanaged. ...

Instantiate Unmanaged Class From .NET

I'm finding plenty of examples through Google of how to call an API function within an unmanaged DLL from .NET code, but what about instantiating an object from that unmanaged code? I'm currently tinkering with an old legacy application at work (and I'm yet unconvinced that we're going to be able to do anything with this, but tinker and...

what is the difference between "managed" vs "unmanaged"?

I hear/read about it sometimes when talking about .NET, for example "managed code" and "unmanaged code" but I have no idea what they are and what are their differences. What are their difference, by definition? What are the consequences of using either of them? Does this distinction exist in .NET/Windows only? ...

Convert array<int^>^ to int*

how can I convert array<int^>^ to int*? ...

Unmanaged memory management in D

What's the best way to avoid using GC in D? Is there a way to use classes that doesn't involve their memory being managed, or do you have to use pointers to malloc'd structs like you would in C and C++? ...

Destructor not called while debugging in VS 2010

Hello, I have a C# project in which managed C++ class is used. This managed C++ class is wrapping an unmanaged C++ code. I have code block like this; if (true) { ManagedFoo foo = new ManagedFoo(); } //GC.Collect(); // I also tried with this one but result is same I have placed a simple output string t...

how do i use the c++ dll in c#

i like import c++ dll in my c# application how can i Do this?, what is concept i need to use for this? ...

Port unmanaged C++ project to C#

Hi SO, for several reasons I need to port a C/C++ unmanaged project (VS 2008) to C# (preferably .net 3.5). I'd need to know: whether, by any chance, exist some conversion-helping tools; let's say something translating the code syntax and asking you verifications/modifications for each problematic point (I guess I'm dreaming...) where...