unmanaged

Unmanaged C++ Garbage Collection help

I'm a .net programmer, without much experience with unmanaged code. I've been adding modifications and additions to an unmanaged project, and everything is functioning just fine. Can you give me some pointers as to what kind of code/objects I need to be concerned about in regard to garbage collection? TIA ...

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 unmanaged code permission is available to avoid three potential stack walks bool internalUn...

How to grant unmanaged code acess to a windows forms hosted in a html?

I am trying to host a windows forms control in C# inside an html page and then host that web page in IIS in order to be accessible by other client machines. The problem is: the usercontrol uses some unmanaged code, which triggers a securitypermission exception when accessing using another machine. I've managed to dumb down my code to a...

.NET events to C++ COM client

Adam Nathan in his book ".NET and COM" demonstrates how to hook up events from a C# library to a COM client, but the client code is shown only with a VB sample--I need C++. The C# client implements the Phone class: [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] public interface IPhoneEvents { [Dispid(1)] void Ring(); } publi...

passing an unmanaged function pointer callback to managed code using C++ interop

Hi all, I'm trying to add some managed code into an existing c++ GUI application. I'd like to get a functional callback working...specifically, I'd like to pass a method pointer from UNMANAGED code to MANAGED code and have the managed code invoke the callback. I'm looking at something like this: typedef int (__stdcall *ANSWERCB)(int)...

Access Violation with unmanaged DLL

Currently, we use an unmanaged DLL from a vendor that allows us to access a particular instrument. The particular function of interest is specified in a header file as this: extern "C" short CCONV acq_get_board_count (); In my application, I have the pinvoke statement: public class bograms { [DllImport("bograms.dll", EntryPoint =...

How can I get at unmanaged globals from C#?

I'm writing a .NET wrapper for an unmanaged DLL. The original DLL is C++ with a C shim that basically just replicates the API in C form, so that language bindings aren't such a pain. I've already written a Python binding for it, so I know what I'm trying to do should work. The DLL has a number of callbacks exported as global members, ...

Dynamically binding a DLL function with unknown return types and parameters

Hello All, This question is related to my previous question - http://stackoverflow.com/questions/3632473/dynamically-running-a-dll-at-a-remote-windows-box First of all, thanks for all your helpful insights. I have found a way to run a DLL at a remote machine. Now what I am trying to do is as follows. (1) send a DLL to the remote m...

Global dictionary vs. GCHandle

Hey, I am required to pass some sort of identifier to unmanaged code which then processes a request and calls back into my managed code once it has done some processing. I was wondering whether it would be better to create a GCHandle and pass it to the unmanaged code to then recover the object once the unmanaged code passes the GCHandl...

COM vs tightly wrapped managed c++ objects

So, there is a legacy code that has to be imported into .NET projects. Which one do you preffer, and why: packing it into COM module or making small and tight c++ managed wrapper around it There is third option of exporting the functions in the DLL, but let's say that we want classes here. ...

Defining a delegate as a function pointer

I am using a delegate which calls an unmanaged function pointer. This causes the Garbage Collector to collect it before it is used, as described in the CallbackOnCollectedDelegate MDA page on MSDN: MSDN page for CallbackOnCollectedDelegate MDA. The resolution states that I have to marshal the appropriate delegate as an unmanaged functio...

Catch a .NET error that only happens on Release, no exception thrown

I currently am witnessing an error that only happens on "Release" mode of my exe. Therefore, I have no debugger attached, and the application only goes "... has stopped working.". My initial reflex was to catch any and all exception in my main loop and display its message, but turns out none is thrown, the program just crashes. (My pro...

Error accessing unmanaged dll in .net wcf

I have a WCF referencing a managed assembly in the project. The managed assembly inturn invokes an unmanaged assembly which is copied to the bin folder of the WCF. During runtime, calling any method in managed assembly throws exception "Attempted to read or write protected memory. This is often an indication that other memory is corrupt....

how to track dlls being loaded into a process?

I am looking for a tool to trace the dlls being loaded into a process on windows. The app i have is loading managed and unmanaged dlls, but not sure if the managed ones are loading the unmaanged ones. Process Explorer and File Explorer doesn't seem to help much. Any thoughts?? thanks!! ...

What are the different ways of combining C++ and C#?

Possible Duplicate: Writing a DLL in C/C++ for .Net interoperability I am writing a school project in C++, where I would like to have a GUI written in C# with WPF. This leads me to my question: What are the different ways of combining unmanaged C++ and C# and what are the advantages of each? Preferably I would like to have ...

Calling unmanaged code from ASP.NET in IIS7

Hi, I call a DLL in ASP.NET a DLL that is written in C++. When running it into IIS 7, The pool (w3wp.exe) crash and the "just in time debugging window" open. I do many tracing and I found that crash happen when calling any function (in the unmanaged DLLs) that have a "out string" parameter (or return a string value). I saw on the web t...

Howto call an unmanaged C++ function with a std::vector as parameter from C#?

Hi! I have a C# front end and a C++ backend for performance reasons. Now I would like to call a C++ function like for example: void findNeighbors(Point p, std::vector<Point> &neighbors, double maxDist); What I'd like to have is a C# wrapper function like: List<Point> FindNeigbors(Point p, double maxDist); I could pass a flat array...

Fastest way to chop array in two pieces

I have an array, say: var arr1 = new [] { 1, 2, 3, 4, 5, 6 }; Now, when my array-size exceeds 5, I want to resize the current array to 3, and create a new array that contains the upper 3 values, so after this action: arr1 = new [] { 1, 2, 3 }; newArr = new [] { 4, 5, 6 }; What's the fastest way to do this? I guess I'll have to look...

Calling COM wrapped c# dll from unmanaged c++: how to pass a 'string' and retrieve an updated value

I use COM interop to call functions in a c# dll from my VC6 MFC DLL, and this works fine. I want to call a function to retrieve string values. How do I declare a 'string' in my unmanaged C++? How should the 'string' appear in the c# code? Currently the c# function in the dll takes ref string arguments, and my c# test app works fine, but ...

Freeing up of unmanaged code in C#

I call a piece of an unmanaged C++ code from my C# application to calculate fast fourier transform of a discrete time signal. I make a call something like this IntPtr ptr = ComputeFFTW(packetSig, packetSig.Length, (int)samplFrequency,(int)fftPoints); unsafe { double *dPtr = (double*)ptr; for(int l = 0; ...