unmanaged

What kind of assemblies can be called using P/Invoke ?

Hi all, I allready asked at: Is it possible to call unmanaged code using C# reflection from managed code ? if it is possible to call C/C++ library unmanaged function with Invoke and reflection from .NET and the answer is yes. What I am not clear about is can I call using P/Invoke ANY assembly written/compiled/build with other compile...

Getting strange error when attempting to convert Unmanaged C++ class to Managed C++ class (for use in .net)

Greetings, First off, I am not a C++ developer, so please forgive my shortcomings.... I am attempting to take another developer's C++ unmanaged code and re-work it so it can be called from a managed DLL from our c#.net application. Please keep in mind that I'm a .net developer, and I haven't touched C++ in like 12 years. And when I ...

How is unmanaged code run in .NET?

How does unmanaged code run in .net? ...

How to expose classes that implement interfaces and use unmanaged resources?

Hi. I have a question regarding use of interfaces when unmanaged resources come to play. Suppose I have a web service and generated WCF client. Service contract looks like this: [ServiceContract] public interface ITestService { [OperationContract] string GetData(int value); } On client side I use dependency injection and bind...

LNK 2028 - 2019 / Managed and Unmanaged C++ ? (VS 2008)

Hi, I am trying to link an open-source library to one of my project. The library is unmanaged (named Tetgen) and my project is in managed C++. I create a .lib or a .dll, that doesn't change anything. My project recognizes the header and can use the functions defined in it, but cannot access to the cpp. I got a 2028 error each time it wa...

How to use Unmanaged Exports in Delphi

I'm making a project in C# and I want to use Unmanaged Exports and later to use it in Delphi. So can anyone explain me, how does Unmanaged Exports works, then how to use/import in Delphi. I'm using Visual Studio 2010 Express, on Windows 7 64 bit ...

How to save bitmap to TIFF file (win32)?

What's the easiest way to save a bitmap (I have an HBITMAP handle) to a TIFF file using unmanaged Win32? It would be trivial using GDI+, but I'm limited to GDI. Thanks in advance! ...

Referencing unmanaged librararies from managed code, adventages and disadvantages ?

HI all, I would like to call from my C# code, unamanaged library functions like presented below. There are two options and the both works. In this moment "Beep" function is simple and have no input/output parameters, pointers, references... I am wondering in more complex cases what would be adventages and disadvantage of both approches ...

passing unmanaged pointer field contained in managed class to unmanaged code

I have a managed class which contains unmanaged class pointer: class Managed { public IntPtr ptr; }; c++ function which takes a pointer as parameter: void foo(void *ptr); should i pin this Managed object before calling the unmanaged function? calling code: Managed obj = new Managed; foo(obj.ptr); ...

How do I protect my C# app from crashing when calling a method in an unmanaged DLL?

I have an unmanaged DLL written by another developer in unmanaged C++. My application is a WinForms application written in C#. I am using interop to call a method (function) in the native DLL. The call is causing my application to crash upon executing the method. How does one safely call a method using interop, so that it does not bring...

Enable Unmanaged Debugging always causes Visual Studio crash

Never before had any problems with enabling unmanaged debugging. I'm using Vista, VS Team System 2008 (9.0 30729.1 SP) and VS 2005 Team Edition for Software Developers (8.0.50727.867). Starting today I cannot debug unmanaged code from C#! I cannot even set a check on enabling unmanaged debugging for an empty C# console project with no...

.NET - Copy from Unmanaged Array to Unmanaged Array

I've been looking through the Marshal class, but I can't seem to find a method that allows me to copy from an unmanaged array (IntPtr) to another unmanaged array (IntPtr). Is this possible using .NET? ...

How to pass Object array to unmanaged code?

I'm trying to pass an array of objects from C# to unmanaged C++, and nothing seems to work. The compiler won't let me pretend the array is an IntPtr. Casting the array to an IntPtr doesn't work. I've tried to pass the address of pinned data, but this didn't work either. I just need to pass a pointer to the beginning of the array, and...

The Symbol file MyFile.pdb does not match the module

I've searched on this issue, and found many flavors and ideas but no real solutions. So, donning my asbestos suit and hoping for the best, I'm going to dare ask it again. I have managed C# code that calls managed C++ code, which in turn calls unmanaged C++ code. The unmanaged C++ code is throwing an exception, and I'd like to be able ...

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 NativeMethod(double inD, IntPtr outD); Then to use the DLL I did IntPtr x = Marshal.All...

Can I Call unmanaged Mobile CE Dll from Full .Net Framework (Run on Desktop)

I have an Unmanaged Lib compiled for Windows Ce. I am trying to call this dll from VB.net Full Framework .Net 4 Client Profile Windows application. I am trying to use the same code that I use in the Compact Framework application. It compiles without errors and runs but when Invoking a function I get error ex = {"An attempt was made to lo...

Application Crashes when Code Optimization option is enabled

Hello, I'm having the following problem: I'm developing a C# application which requires unsafe code to call an unmanaged c++ function. The structure is: [StructLayout(LayoutKind.Sequential)] unsafe struct DataStruct { public UInt16 index; public UInt16 response; public byte* addr; //this is a pointer to a byte array which s...

How to marshall c++ char* to C# string using P/INVOKE

Hey guys, I'm new to C++. I'm calling a C++ function from C# using a PINVOKE and wanting to get a string back as an out parameter. However I just get an empty string back. The int out parameter works fine. Importing: [DllImport ( @"UnamanagedAssembly.dll", CharSet = CharSet.Ansi)] public static extern int Activate(ref int numActivat...

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 organize the dlls? IL code of DotNet.dll will be the same for both 32-bit and 64-bit ...

Calling a C++ function from C# - unbalanced stack

Hello. I have a unmanaged C++ function with the following signature: int function(char* param, int ret) I am trying to call it from C#: unsafe delegate int MyFunc(char* param, int ret); ... int Module = LoadLibrary("fullpathToUnamanagedDll"); IntPtr pProc = GetProcAddress(Module, "functionName"); MyFunc func = (MyFunc)System.Runt...