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.
Questions tagged [unmanaged]
1488 questions
8
votes
2 answers
Is it possible to unit test a class that makes P/Invoke calls?
I want to wrap a piece of code that uses the Windows Impersonation API into a neat little helper class, and as usual, I'm looking for a way to go test-first. However, while WindowsIdentity is a managed class, the LogonUser call that is required to…

Rytmis
- 31,467
- 8
- 60
- 69
8
votes
2 answers
What is the difference between managed and unmanaged DLL
I am a newbie....I would really like to know detailed difference between two, and when to use these?

nightWatcher
- 1,051
- 3
- 15
- 28
8
votes
3 answers
Wrapping unmanaged C++ with C++/CLI - a proper approach
as stated in the title, I want to have my old C++ library working in managed .NET. I think of two possibilities:
1) I might try to compile the library with /clr and try "It Just Works" approach.
2) I might write a managed wrapper to the unmanaged…

Jamie
- 1,092
- 3
- 22
- 44
8
votes
1 answer
Is it safe to rename extern method parameters in C#?
I am currently cleaning up some of our legacy code base in which we make use of extern methods. The parameter names are all over the place in terms of naming conventions. I'd like to consolidate them.
Example
[DllImport("customdll",…

Mario Tacke
- 5,378
- 3
- 30
- 49
8
votes
5 answers
Database Access Libraries for C++
Background:
I have an application written in native C++ which uses the wxWidgets toolkit's wxODBC database access library which is being removed from all future versions of wxWidgets . I need to replace this with another database access method that…

Zach Burlingame
- 13,476
- 14
- 56
- 65
8
votes
3 answers
Loading C# DLL with unmanaged exports into Python
I’ve built a C# DLL (MyTestDll) using the NuGet package UnmanagedExports:
[DllExport("Test", CallingConvention = CallingConvention.Cdecl)]
public static string Test(string name)
{
return "hi " + name + "!";
}
I use it from Python via ctypes DLL…

Dmitry
- 581
- 1
- 4
- 15
8
votes
3 answers
Call c++ library from c#
This question might seem a repeat of previous ones. I have read through a series of posts, but not completely clear for my situation.
I have a c++ library which is created using momentics IDE. I have to be able to use this library into a c# project.…

Batul
- 85
- 1
- 1
- 7
8
votes
4 answers
Unmanaged DLLs in C++
I've been reading many a tutorial/article on unmanaged DLLs in C++. For the life of me, however, I cannot seem to grasp the concept. I'm easily confused by the seeming disagreement about whether it needs a header file, how to export it, whether I…

Peter C.
- 423
- 2
- 6
- 12
8
votes
4 answers
Referencing an unstable DLL
We are referencing a 3rd party proprietary CLI DLL in our .net project. This DLL is only an interface to their proprietary C++ library. Our project is an asp.net (MVC4/Web API) web application.
The C++ unmanaged library is rather unstable. Sometimes…

Schiavini
- 2,869
- 2
- 23
- 49
8
votes
4 answers
Why doesn't IntPtr need the unsafe keyword?
When you use a pointer like int* in C#, you need to use the unsafe keyword, but when you use an IntPtr, you don't. What is the difference of these? They both can point to an address.
How does the garbage collector deal with these two types? Are they…

hattenn
- 4,371
- 9
- 41
- 80
8
votes
3 answers
Merge several native DLLs into one DLL
I've got a lot of small DLLs which I would like to make into one big(er) DLL (as suggested here). I can do so by merging my projects but I would like a less intrusive way.
Can several DLLs be merged into one unit?
A quick search found this thread…

Motti
- 110,860
- 49
- 189
- 262
8
votes
3 answers
Using ref struct or class with P/Invoke
I know this subject was discussed many times here, but I couldn't find the answer for my specific situation.
I need to call in C# an unmanaged C method which takes a pointer on a struct object (I don't speak C fluently :
int doStuff(MYGRID* grid,…

Eric David
- 261
- 3
- 14
8
votes
1 answer
How to allocate memory with a 16 byte alignment?
I use Marshal.GlobalHAlloc to allocate memory. As documentation says: "This method exposes the Win32 LocalAlloc function from Kernel32.dll.". GlobalAlloc's documentation says it will be 8 byte aligned but LocalAlloc don't say anything about align. …

apocalypse
- 5,764
- 9
- 47
- 95
8
votes
4 answers
the correct technique for releasing a socket/event/ummaged code with the dispose/finalize pattern
How to implement the Dispose pattern when my class contains a socket & event?
Should it be something like this?
class MyClass
{
Socket m_ListenerSocket = new Socket();
book m_Disposed=false;
public void Dispose()
{
Dispose(true);
…

roman
- 607
- 2
- 10
- 18
8
votes
2 answers
Marshaling pointer to an array of strings
I am having some trouble marshaling a pointer to an array of strings. It looks harmless like this:
typedef struct
{
char* listOfStrings[100];
} UnmanagedStruct;
This is actually embedded inside another structure like this:
typedef struct
{
…

Dilip
- 213
- 2
- 3
- 9