Questions tagged [unmanaged]

Unmanaged refers to Windows code that is independent of the Common Language Runtime(CLR). COM components, ActiveX components, and Win32 API functions are examples of unmanaged code.

1488 questions
6
votes
2 answers

HOWTO: Call Managed C# Interface From Unmanaged C++ On WindowsCE Compact Framework

I have extensive unmanaged Windows CE 5 C++ code that provides a UI that I want to use in a new product by combining it with a large amount of newer business and communications logic written in managed C# on Windows CE 6 and the Compact…
James Barnard
  • 266
  • 2
  • 5
6
votes
8 answers

Mixing C# Code and umanaged C++ code on Windows with Visual Studio

I would like to call my unmanaged C++ libraries from my C# code. What are the potential pitfalls and precautions that need to be taken? Thank you for your time.
David Segonds
  • 83,345
  • 10
  • 45
  • 66
6
votes
2 answers

Allocation and deallocation of memory in unmanaged code using platform Invoke (C#)

I want to allocate and deallocate memory in unmanaged code (C++) and we call them functions from managed code (C#). Iam not sure whether the following code is fine without memory leaks or not? C# code: [DllImport("SampleDLL.dll")] public extern void…
user186246
  • 1,857
  • 9
  • 29
  • 45
6
votes
3 answers

How do I call unmanaged C/C++ code from a C# ASP.NET webpage

I have an ASP.NET website that uses C# and I'd like to call functions from an unmanaged C/C++ DLL. How do I do it?
Mendokusai
  • 1,313
  • 2
  • 16
  • 20
6
votes
2 answers

How does Marshal.ReadInt32 etc. differ from unsafe context and pointers?

Particularly: Is Marshal safer? Are pointers faster? int pixel = Marshal.ReadInt32(bitmapData.Scan0, x * 4 + y * bitmapData.Stride); int pixel = ((int*)bitmapData.Scan0)[x + y * bitmapData.Stride / 4];
Ansis Māliņš
  • 1,684
  • 15
  • 35
6
votes
3 answers

Managed and Unmanaged heap

What is an unmanaged heap? I thought any object based memory that the CLR manages was the managed heap, so why do we talk about an unmanaged heap?
WPF-it
  • 19,625
  • 8
  • 55
  • 71
6
votes
2 answers

How do i determine if a ConstructorInfo object has an unmanaged parameter?

My app uses reflection to analyze c++/cli code in runtime. I need to determine if a type has a constructor without unmanaged parameters (pointers and such), because i want later on to use: ConstructorInfo constructorInfo; // ... var ret =…
seldary
  • 6,186
  • 4
  • 40
  • 55
6
votes
2 answers

Passing Unmanaged pointers in C++/CLI

I'm creating a C++/CLI wrapper DLL that depends on numerous C++ static libraries. Some of the function calls expect unmanaged pointers to be passed in. How do i pass them properly? Also, other functions expect a "this pointer" to be passed in as a…
cjserio
  • 2,857
  • 7
  • 29
  • 29
6
votes
3 answers

Implementing a generic unmanaged array in C#

I'm implementing an unmanaged array class in C# which I need for some OpenGL calls. It's going great, but I've hit a roadblock. The following code doesn't compile, and I understand why, but how can I make it work? public T this[int i] { …
Hannesh
  • 7,256
  • 7
  • 46
  • 80
6
votes
1 answer

Unmanaged memory not showing up in task manager

I wrote the following test (actually used in a wider context) IntPtr x = Marshal.AllocHGlobal(100000000); Console.Write("Press any key to continue . . . "); Console.ReadKey(true); Marshal.FreeHGlobal(x); Console.ReadKey(true); Why doesn't the…
oliver
  • 2,771
  • 15
  • 32
6
votes
2 answers

What is the best unit testing tool for a mix of managed and unmanaged C++?

I am going to start implementing some unit tests for a codebase that is a mix of managed and unmanaged C++. Can NUnit hack it with unmanaged code? Is there a better alternative?
Brian
  • 5,826
  • 11
  • 60
  • 82
6
votes
1 answer

managed code vs unmanaged code

I'm trying to get my mind wrapped around the concept of managed vs unmanaged code. Correct me if I'm wrong but managed code is anything that gets compiled down to bytecode while unmanaged code gets compiled down to machine code. Is this correct?
conterio
  • 1,087
  • 2
  • 12
  • 25
6
votes
6 answers

Catch a .NET error that only happens on Release, no exception thrown

I currently am witnessing an error that only happens on "Release" mode of my exe. Therefore, I have no debugger attached, and the application only goes "... has stopped working.". My initial reflex was to catch any and all exception in my main loop…
Lazlo
  • 8,518
  • 14
  • 77
  • 116
6
votes
5 answers

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…
Elan
  • 6,084
  • 12
  • 64
  • 84
6
votes
2 answers

.NET - Copy from Unmanaged Array to Unmanaged Array

I've been looking through the Marshal class, but I can't seem to find a method that allows me to copy from an unmanaged array (IntPtr) to another unmanaged array (IntPtr). Is this possible using .NET?
user113476