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
8
votes
4 answers

How to run unmanaged executable from memory rather than disc

I want to embed a command-line utility in my C# application, so that I can grab its bytes as an array and run the executable without ever saving it to disk as a separate file (avoids storing executable as separate file and avoids needing ability to…
Triynko
  • 18,766
  • 21
  • 107
  • 173
8
votes
1 answer

How to create .NET independent apps using Visual Studio?

There exist many C++ IDEs. However, I find Visual Stuido (Visual Studio 2010 Pro) the most comfortable maybe because I've spent a lot of time with it. The problem is I really don't like .NET dependent products both speed-wise and…
gunakkoc
  • 1,069
  • 11
  • 30
7
votes
6 answers

In managed code, what should I look after to keep good performance?

I am originally a native C++ programmer, in C++ every process in your program is bound to your code, i.e, nothing happens unless you want it to happen. And every bit of memory is allocated (and deallocated) according to what you wrote. So,…
Tamer Shlash
  • 9,314
  • 5
  • 44
  • 82
7
votes
2 answers

Best way to call Managed .NET code from Unmanaged code

I'm trying to find the best performing method of calling into Managed .NET code from Unmanaged C++ code. I have found information on Hosting .NET within my C++ application and I'm able to create a pRuntimeHost and start it without a problem. The…
Andrew Stern
  • 688
  • 9
  • 18
7
votes
2 answers

Memory leak detection for mixed mode projects: managed, unmanaged and native

I have a Visual Studio 2010 solution that contains C# (managed), C++/CLI (unmanaged) and pure C++ (native) projects. I would like to perform memory leak detection across all 3 projects or at least around the native code: The C# project references…
Kiril
  • 39,672
  • 31
  • 167
  • 226
7
votes
2 answers

How can I send a managed object to native function to use it?

How can I send a managed object to native function to use it? void managed_function() { Object^ obj = gcnew Object(); void* ptr = obj ??? // How to convert Managed object to void*? unmanaged_function(ptr); } // The parameter type should be…
Amir Saniyan
  • 13,014
  • 20
  • 92
  • 137
7
votes
2 answers

How to convert an IntPtr back into an object

All, this is a follow up from a previous question here: C# formatting external Dll function parameters Here specifically is the code that I am trying to convert to C#: FILES_GetMemoryMapping((LPSTR)(LPCTSTR)MapFile, &Size, (LPSTR)MapName,…
Nick
  • 2,913
  • 12
  • 40
  • 52
7
votes
3 answers

The 'fixed' statement in C# and managed pointer in CIL code

In unsafe code in C#, I assigned a pointer to the managed variable of an array type: int[] array = new int[3]; // ... fixed (int* ptr = array) { // Some code } Then I looked at corresponding part of the IL code: .locals init ([0] int32[]…
vldmrrdjcc
  • 2,082
  • 5
  • 22
  • 41
7
votes
1 answer

Free unmanaged c-code memory in managed C#

I have a large c-code library that used to write its results to file. I converted it to return it's data via a float* array to a C++ program like such (to avoid constant file I/O): float* mgrib(...) This worked fine in c++ where I could "free" the…
Anthony
  • 7,638
  • 3
  • 38
  • 71
7
votes
0 answers

How to communicate with hosted CoreCLR?

.NET Framework presents several methods of hosting managed runtime. One can use mscoree.dll's CorBindToRuntime (https://msdn.microsoft.com/library/ms231419(v=vs.110).aspx) to get handle of AppDomain via GetDefaultDomain/CreateDomain, and then load…
Andrey Paramonov
  • 409
  • 4
  • 11
7
votes
1 answer

UnmanagedCode permission. What is it?

The following code exists in LogEntry.cs in the Enterprise Library's Logging Application Block: private bool UnmanagedCodePermissionAvailable { get { if (!unmanagedCodePermissionAvailableInitialized) { // check whether the…
wageoghe
  • 27,390
  • 13
  • 88
  • 116
7
votes
3 answers

What is the best way to support multiple architectures in a mixed managed/unmanaged environment?

Background We have a .NET library that is referencing one of our unmanaged dlls, lets say: DotNet.dll Unmanaged.dll Thus far, Unmanaged.dll is only 32-bit, so the DotNet.dll is marked with 32-bit CPU type. 64-bit support needs to be added. How to…
earlNameless
  • 2,878
  • 20
  • 25
7
votes
3 answers

Correct usage of DllImport

Suppose there is a c++ method int NativeMethod(double, double *) in a Native.dll. My first attempt at calling this method from managed code was (assuming I don't need to specify the entry point) [DllImport("Native.dll")] private static extern int…
insipid
  • 3,238
  • 3
  • 26
  • 38
7
votes
2 answers

Is it possible to call unmanaged code using C# reflection from managed code?

Is it possible using reflection and C# .NET to call dynamically different function (with arguments) written in C or C++ before .NET came (unmanaged code) ? A small C# example if possible would be appreciated!
milan
  • 213
  • 3
  • 10
7
votes
1 answer

SafeHandle and HandleRef

After reading about both, including a high voted answer on this site, I still find this a bit unclear. Since my understanding of the matter might be wrong, I'll first post a synopsis of what I know so I can be corrected if I'm wrong, and then post…
ispiro
  • 26,556
  • 38
  • 136
  • 291