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
7
votes
2 answers

How do I combine an unmanaged dll and a managed assembly into one file?

SQLite from PHX Software has combined a managed assembly (System.Data.SQLite) with an unmanaged dll (the SQLite 32- or 64-bit dll) into one file, and managed to link them together. How do I do this? Do I need to embed the managed assembly into the…
Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
7
votes
2 answers

MSBuild Managed vs Unmanaged property

Is there a way in MSBuild logic to determine if I am running managed vs unmanaged code? Not C++ vs C#, but just managed vs unmanaged? I'd like to set some properties (usually just version information) differently depending on whether the code is…
Eric Kulcyk
  • 279
  • 3
  • 15
7
votes
2 answers

How can I declare constant strings for use in both an unmanaged C++ dll and in a C# application?

Curently I'm passing my const string values up from my C++ into my C# at startup via a callback, but I'm wondering if there's a way of defining them in a C++ header file that I can then also refer to in C#. I already do this with enums as they are…
Surfbutler
  • 1,529
  • 2
  • 17
  • 38
7
votes
2 answers

Marshal.PtrToStringUni() vs new String()?

Suppose i have a pointer of type char* to unicode string, and i know the length: char* _unmanagedStr; int _unmanagedStrLength; and i have 2 ways to convert it to .NET string: Marshal.PtrToStringUni((IntPtr)_unmanagedStr,…
DxCK
  • 4,402
  • 7
  • 50
  • 89
7
votes
5 answers

Creating a managed wrapper for 32bit and 64bit unmanaged DLL

We are creating a C# wrapper around a unmanaged DLL. The unmanaged DLL comes in both a 32 and 64bit versions. We keep the managed wrapper in its own project so that we can build it as a separate component and reuse it across solutions. However this…
flalar
  • 1,181
  • 3
  • 12
  • 23
7
votes
3 answers

Can an .Net exception be raised from unmanaged code using a delegate function?

I searched around SO and found various related questions, some answered with essentially "don't do that." I want to call some unmanaged C++ code that accesses various existing C++ code. The existing code may have a variety of error conditions that…
Marvin
  • 2,537
  • 24
  • 35
7
votes
7 answers

Free unmanaged memory allocation from managed code

A .NET application calls C dll. The C code allocates memory for a char array and returns this array as result. The .NET applications gets this result as a string. The C code: extern "C" __declspec(dllexport) char* __cdecl Run() { char* result =…
Alex
  • 321
  • 1
  • 5
  • 14
7
votes
4 answers

C++ internal code reuse: compile everything or share the library / dynamic library?

General question: For unmanaged C++, what's better for internal code sharing? Reuse code by sharing the actual source code? OR Reuse code by sharing the library / dynamic library (+ all the header files) Whichever it is: what's your strategy for…
sivabudh
  • 31,807
  • 63
  • 162
  • 228
7
votes
1 answer

64 bit managed assembly with unmanaged dependencies not loading in IIS / ASP.NET MVC 4

I have an almost empty ASP.NET MVC4 project referencing a 64 bit managed assembly, which has a set of unmanaged dependencies. The managed assembly is referenced the normal way through references. The unmanaged dependencies are copied to the bin…
cwt237
  • 267
  • 3
  • 9
7
votes
4 answers

Mapping unmanaged data to a managed structure in .NET

I have spent many hours working with unmanaged code, and platform invoke in .NET. The code below illustrates something that is puzzling me regarding how unmanaged data is mapped to a managed object in .NET. For this example I am going to use the…
Matthew Layton
  • 39,871
  • 52
  • 185
  • 313
7
votes
3 answers

Which managed classes in .NET Framework allocate (or use) unmanaged memory?

Is there a known (documented) set of .NET types that allocate memory in the unmanaged portion of the process' memory? For example, Microsoft documents that the WPF infrastructure allocated unmanaged memory for its retained rendering model in order…
LBushkin
  • 129,300
  • 32
  • 216
  • 265
7
votes
4 answers

How can I in C# stream.Read into unmanaged memory stream?

I can read unmanaged memory in C# using UnmanagedMemoryStream, but how can I do the reverse? I want to read from a managed stream directly into unmanaged memory, instead of first reading into a byte[] and then copying. I'm doing async stream…
Rabbit
  • 1,741
  • 2
  • 18
  • 27
7
votes
4 answers

Find out what a random number generator was seeded with in C++

I've got an unmanaged c++ console application in which I'm using srand() and rand(). I don't need this to solve a particular problem, but was curious: is the original seed passed to srand() stored somewhere in memory that I can query? Is there any…
Brian
  • 5,826
  • 11
  • 60
  • 82
7
votes
3 answers

Autowiring Unmanaged Beans Annotated With @Component

I want to use @AutoWired to inject a non-managed bean configured with @Component into a managed bean. I'm pretty sure I have the configuration right, but for some reason I keep getting the exception: No unique bean of type [foo.Baz] is defined:…
Alex Beardsley
  • 20,988
  • 15
  • 52
  • 67
6
votes
2 answers

Multiple function calls from C# to C++ unmanaged code causes AccessViolationException

I have declared a DLL import in my C# program that looks like this: [DllImport("C:\\c_keycode.dll", EntryPoint = "generateKeyCode", CallingConvention = CallingConvention.Cdecl)] static extern IntPtr generateKeyCode(char[] serial, char[]…
Sean Glover
  • 520
  • 6
  • 22