Managed refers to code that requires and will only execute under the control of a Common Language Runtime (CLR). Any code written in C# or Visual Basic .NET is managed code.
Questions tagged [managed]
890 questions
176
votes
13 answers
What is managed or unmanaged code in programming?
I am using a specific command in in my C# code, which works well. However, it is said to misbehave in "unmanaged" code.
What is managed or unmanaged code?

Pokus
- 11,383
- 11
- 37
- 27
148
votes
5 answers
What is meant by "managed" vs "unmanaged" resources in .NET?
What is meant by the terms managed resource and unmanaged resource in .NET? How do they come into the picture?

Red Swan
- 15,157
- 43
- 156
- 238
146
votes
3 answers
Difference between "managed" and "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…

Louis Rhys
- 34,517
- 56
- 153
- 221
113
votes
6 answers
Marshaling – what is it and why do we need it?
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…
george9170
100
votes
7 answers
How to get parent process in .NET in managed way
I was looking a lot for method to get parent process in .NET, but found only P/Invoke way.

abatishchev
- 98,240
- 88
- 296
- 433
99
votes
7 answers
Possible to call C++ code from C#?
Is it possible to call C++ code, possibly compiled as a code library file (.dll), from within a .NET language such as C#?
Specifically, C++ code such as the RakNet networking library.
yiingchau
92
votes
5 answers
Embedding unmanaged dll into a managed C# dll
I have a managed C# dll that uses an unmanaged C++ dll using DLLImport. All is working great.
However, I want to embed that unmanaged DLL inside my managed DLL as explain by Microsoft…
Laurent
75
votes
6 answers
What is the difference in managed and unmanaged code, memory and size?
After seeing and listening a lot regarding managed and unmanaged code, and knowing the only difference is that managed is about CLR and un-managed is outside of the CLR, it makes me really curious to know it in detail. What is it all about, managed…

Simsons
- 12,295
- 42
- 153
- 269
67
votes
4 answers
Difference between native and managed code?
For example, when looking at the GlowCode profiler website it says:
GlowCode 6.2 and x64 profile native, managed, and mixed C++, C#, .NET code
What do they mean?

Joel
- 15,166
- 16
- 39
- 31
61
votes
3 answers
WinApi - GetLastError vs. Marshal.GetLastWin32Error
I tested a lot. But I found no disadvantages of those 2!
But see the accepted answer.
I read here that calling GetLastError in managed code is unsafe because the Framework might internally "overwrite" the last error. I have never had any noticeable…

Bitterblue
- 13,162
- 17
- 86
- 124
56
votes
21 answers
Memory Leak in C#
Is it ever possible in a managed system to leak memory when you make sure that all handles, things that implement IDispose are disposed?
Would there be cases where some variables are left out?

Joan Venge
- 315,713
- 212
- 479
- 689
50
votes
5 answers
A call to PInvoke function '[...]' has unbalanced the stack
I'm getting this weird error on some stuff I've been using for quite a while. It may be a new thing in Visual Studio 2010 but I'm not sure.
I'm trying to call a unamanged function written in C++ from C#.
From what I've read on the internet and the…

Sanctus2099
- 1,669
- 5
- 22
- 40
50
votes
2 answers
Unmanaged memory and Managed memory
what exactly are un-managed and managed memory?
can anybody explain me in brief?
Also, what exactly would mean when the managed-memory concept is taken to RAM, calling managed-RAM. What are some of the specifics about "managed RAM" and…

Naruto
- 9,476
- 37
- 118
- 201
33
votes
1 answer
How do I do typeof(int) in Managed C++?
I am working on a project now and part of it uses Managed C++. In the managed C++ code, I am creating a DataTable. While defining the Columns for the datatable, I need to specify the Type of the column. In C#, that would:
typeof(int)
but how do I do…

Nazeeh
- 631
- 1
- 6
- 13
31
votes
2 answers
C++/CLI : Casting from unmanaged enum to managed enum
What is the correct way of casting (in C++/CLI) from a native code enum to a managed code enum which contain the same enum values? Is there any difference with using the C# way of casting like for example (int) in C++/CLI.

Lopper
- 3,499
- 7
- 38
- 57