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
10
votes
3 answers

Passing struct from unmanaged C++ to C#

Note: The final working solution is after the edit! I hope someone can help me with a problem I've been trying to solve for the last few days. I am trying to pass a struct from a unmanaged C++ DLL to a C# script. This is what I have so…
mkolarek
  • 527
  • 1
  • 7
  • 16
10
votes
2 answers

Does Unmanaged C# code compile into IL and run on the CLR?

In the midst of asking about manually managing CLR memory, I realized I know very little. I'm aware that the CLR will place a 'cookie' on the stack when you exit a managed context, so that the Garbage Collector won't trample your memory space;…
kd8azz
  • 613
  • 5
  • 21
9
votes
2 answers

Managed to unmanaged overhead

In .NET there are several places when you must leave managed code and enter the realm of unmanaged a.k.a. native code. To name a few: extern dll functions COM invocation There are always comments about overhead that jump from one side to another…
Daniel Mošmondor
  • 19,718
  • 12
  • 58
  • 99
9
votes
6 answers

C# to C++/CLI to C DLL System.IO.FileNotFoundException

I'm getting System.IO.FileNotFoundException: The specified module could not be found when running C# code that calls a C++/CLI assembly which in turn calls a pure C DLL. It happens as soon as an object is instantiated that calls the pure C DLL…
Andy Dent
  • 17,578
  • 6
  • 88
  • 115
9
votes
2 answers

Handling different unmanaged integer sizes

I have a C library. It has many function calls like the following: void init_foo( unsigned long x, unsigned long y ); The library itself is dynamically loaded at runtime (rather like a plugin). The headers are consistent across all platforms. My…
IanNorton
  • 7,145
  • 2
  • 25
  • 28
9
votes
4 answers

Difference between Marshal.SizeOf and sizeof, I just don't get it

Until now I have just taken for granted that Marshal.SizeOf is the right way to compute the memory size of a blittable struct on the unmanaged heap (which seems to be the consensus here on SO and almost everywhere else on the web). But after having…
oliver
  • 2,771
  • 15
  • 32
9
votes
3 answers

Handling exception from unmanaged dll in C#

I have the following function written in C# public static string GetNominativeDeclension(string surnameNamePatronimic) { if(surnameNamePatronimic == null) throw new ArgumentNullException("surnameNamePatronimic"); IntPtr[] ptrs =…
StuffHappens
  • 6,457
  • 13
  • 70
  • 95
9
votes
1 answer

Swift UnsafeMutablePointer?> allocation and print

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…
SamT
  • 528
  • 4
  • 14
9
votes
5 answers

Performance of Calling Unmanaged .dll from C#

How long is the typical overhead added by calling a .dll written in C++ from a C# application using the following syntax? [DllImport("abc.dll", EntryPoint = "xcFoo", CallingConvention = CallingConvention.Cdecl)] public extern static Result Foo(out…
Michael Covelli
  • 2,113
  • 4
  • 27
  • 41
9
votes
1 answer

How to get Visual Studios build system to understand unmanaged dependencies of managed dlls?

When building managed code Visual Studio correctly (and recursively) copies dlls of referenced managed projects to the output folder of the project being build. However, if one the of those references is a managed DLL that depends on unmanaged dlls…
Ziphnor
  • 1,022
  • 1
  • 8
  • 17
9
votes
3 answers

What is the difference between a delegate instance and a method pointer?

I thought that a delegate instance was interchangeable with a function instance. Take the following code: delegate int AddDelegate(int a, int b); AddDelegate DelegateInstance; public void DoStuff() { //I can call this without a delegate…
Jason Young
  • 3,683
  • 4
  • 32
  • 39
9
votes
1 answer

Stack overflow in unmanaged: IP: 0x26eb76, fault addr: 0xbf808ffc

My Mono application crashes on Mac with this message (Full log): $ mono --debug bin/Debug/SparkleShare.app/Contents/MonoBundle/SparkleShare.exe [...] Stack overflow in unmanaged: IP: 0x26eb76, fault addr: 0xbf808ffc [...] "in unmanaged" implies…
Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373
8
votes
4 answers

Unmanaged Memory leak

I have am using a WPF application which uses BitmapSource but I need to do some manipulation but I need to do some manipulation of System.Drawing.Bitmaps. The memory use of the application increases while it runs. I have narrowed down the memory…
aforward
  • 133
  • 1
  • 11
8
votes
3 answers

GetPhysicalMonitorsFromHMONITOR returned handle is always null

On the Media Foundation SDK there is the GetPhysicalMonitorsFromHMONITOR function that I am trying to implement using C# but with no luck ... In the returned PHYSICAL_MONITOR[], the function returns the string description of the monitor but for some…
Aybe
8
votes
1 answer

C# loading an unmanaged DLL: big performance difference between console application and webapp on IIS

I have a webapp written in C#, based on ASP.NET. It loads (with LoadLibraryEx) an unmanaged DLL written with C++Builder. As I have performance issues I made some tests and comparisons, running always the same method in the DLL, for many times,…
bluish
  • 26,356
  • 27
  • 122
  • 180