unmanaged

What is managed/unmanaged code in C#?

I am using Assembly.GetEntryAssembly()... in my C# code to get the version of the application. It runs fine but when I try it in NUnit it returns NULL. In the MSDN it states that it can return NULL when called from unmanaged code. What is managed or unmanaged code? I do not get it. ...

Unmanaged DLLs fail to load on ASP.NET server

This question relates to an ASP.NET website, originally developed in VS 2005 and now in VS 2008. This website uses two unmanaged external DLLs which are not .NET and I do not have the source code to compile them and have to use them as is. This website runs fine from within Visual Studio, locating and accessing these external DLLs corr...

What purpose do unmanaged.dll.manifest files serve?

I observe unmanaged.dll files having a unmanaged.dll.manifest file tagging along. On opening this files in an editor, it seems to be normal XML with links to certain other dependent managed? assemblies. This seems to be like a recent change.. don't remember seeing them earlier. Why are these files needed? (If I had to make a guess, it ...

MX Record Query fails

print("code sample");I'm a managed codeprint("code sample"); guy, so when I interop with unmanaged code, and it doesn't work as advertised, I get twitchy. Can someone explain to me why this would come back with no MX records, when a command line nslookup works? [DllImport("dnsapi", EntryPoint = "DnsQuery_W", CharSet = CharSet.Unicode, S...

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 supports the assumptions and contraints outlined below. I don't require that the replacem...

What is the best unit testing tool for a mix of managed and unmanaged C++?

I am going to start implementing some unit tests for a codebase that is a mix of managed and unmanaged C++. Can NUnit hack it with unmanaged code? Is there a better alternative? ...

Wrapping unmanaged c++ in a managed wrapper

I have an unmanaged C++ library. I would like to expose the functionality for .NET applications. There's one partucular function I am not sure how to handle: typedef void (free_fn*) (void*); void put (void *data, free_fn deallocation_function); The idea is that you pass dynamically allocated buffer to the function and supply a dealloca...

Allocating unmanaged memory in managed .NET code

Hi I have a unmanaged function that takes a chunk of memory allocated by malloc and deallocates it later on in async manner. I want to wrap it into managed wrapper. Is following code OK? void managed_fx (byte data __gc[], size_t size) { // Pin the data byte __pin *pinned_data = &data [0]; // Copy data to the unmanaged buf...

Is there a way to call an unmanaged (not COM) dll from C# application?

Hello, Is there a way to use (reference) a DLL written in an unmanaged C++ (not a COM library) in my C# application? When I try to reference it from within Visual Studio, I get 'not a COM object' error message. Maybe there is some kind of translator\router that would COMify my DLL reference? I have no clue how COM and COM interop work...

Passing custom objects between C# and unmanaged C++

I have a legacy DLL which contains a couple of methods I need to call from C# code. One of these methods takes in a pointer to another C++ class that lives within other C++ programs, not the DLL. I'm pretty sure I need to use pinvoke to marshal the objects back and forth, but I haven't found anything on marshaling custom objects. ...

What tools and techniques can I use to detect and isolate high memory usage in .NET applications which call into significant unmanaged code?

Suppose I have a WinForms .NET application written in C#. This application allocates large amounts of memory from both the managed and unmanaged heaps. I can (relatively) easily figure out the allocation details (who, when, how much, etc.) of the managed objects using tools like Red Gate ANTS Profiler (which I have not used) or JetBrai...

LoaderLock error on program termination

I have recently integrated the .NET NLog logging component into one of our applications which developed purely in unmanaged code (C++ and VB6 components compiled in Visual Studio 6). We have a bunch of C++ application talking to NLog via a COM interface. Everything is working fine at the moment but I do notice that the following message...

Interface from a C DLL to .NET

Hi, I have a legacy DLL written in C that I'd like to call from a C# .NET application. The problem is that the DLL interface for the C DLL is fairly complicated. It's something like this: __declspec(dllexport) void __stdcall ProcessChunk( void *p_prochdl, const BIG_INPUT_STRC *p_inparams, BIG_OUTPUT_STRC *p_outparams ); ...

unmanaged/managed interop - trouble passing int[]

Hello, I am working on my phd in chemistry and for that reason I need to write a software application to help me with the imaging of samples under a microscope. This microscope is fitted with an x-y-z nanopositioning stage. The stage is controlled using an unmanaged DLL written in VC++ by the hardware vendor. I could provide you with mo...

Is there performance penalty on managed code when reading/writing high data volume on TCP/UDP socket compare to unmanaged code?

Do you think C# TCP/UDP socket use in the managed application can handle (roughly) same amount of data as native C++ version? If not, what is data amount we shall consider native or c# is better to use and what is the biggest obstacle in the implementation on managed side? ...

Managed vs Unmanaged

What are your thoughts about them? Sometimes I have to write unmanaged code at work, but with large scale (games) projects, it just becomes way more time-consuming and complicated, which is solved by throwing more people at it. Do you think managed code is viable for large scale applications? (applications like Photoshop, 3ds Max, Maya...

What is Managed/Unmanaged .net code and what difference does it make to me?

I see the terms managed and unmanaged used a fair bit around here. Searching online I can get a fuzzy notion of what they are, but what I really need to know is how it affects me as C# desktop app developer? How do I know which I'm dealing with at any point and how does it change my approach to that code? Duplicate http://stackove...

callback function from unmanaged dll in VB .NET

I'm trying to use an unmanaged dll in VB.NET. The example source code provided with the dll is in VB6 and below is my attempt to convert it to .NET. When the dll tries to do a callback I get a "Attempted to read or write protected memory" exception. I really don't care about the callback function getting actually called. My code: <DllI...

What advantages are there to developing a Win32 app in C++ over a .NET app in C#?

I learned windows programming using Visual C++, and the Win32 API. Nowadays, it seems most apps are being developed in .NET using C#. I understand that most of the time there isn't much performance difference between native code and managed code. So I'm wondering, if I were to start writing a new desktop app today, is there any reason (o...

Emphasize managed or unmanaged in a mixed C++ .NET app?

The app on which I work is a WinForms app written almost entirely in Visual C++ circa 2003. .NET was selected, prior to my arrival on the scene, because of the UI building framework, but the vast majority of code was developed in unmanaged land. Part of that was absolutely necessary--we do some real-time image processing on some very lar...