unmanaged

Passing objects between C# library and C++ (CLR)

对着背影说爱祢 提交于 2019-12-25 01:32:51
问题 How to pass objects from C# library to C++. I can call a function which returns void or int without any issue. Now consider the following function in C#, List<CSharpClass> CSharpFunction(string Input) where my C# class contains, public class CSharpClass { string mystring = string.Empty; byte[] bytearray = null; public byte[] bytearray { get { return bytearray ; } set { bytearray = value; } } public string mystring { get { return mystring ; } set { mystring = value; } } } Now, I want use this

callback function from unmanaged dll in VB .NET

旧街凉风 提交于 2019-12-24 21:33:35
问题 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: <DllImport("AlertMan.dll")> _ Public Shared Function AlertManC( _ ByVal CallbackAddr As AlertManCallbackDel) As Long End Function Public Delegate Sub

Trouble loading Unmanaged C++ DLL from WPF application

隐身守侯 提交于 2019-12-24 05:52:40
问题 First of all I would like to thank anyone reading this for their time! I'm a pretty well-informed C# programmer with WinForms and I'm giving WPF a shot. I've been having trouble calling functions from my WPF application so I decided to create a very easy example project to illustrate my problem. In this application I'm creating a C++ Dll (using Visual Studio 2012 -> Visual C++ -> Win32 Console Application -> .DLL Project). In this DLL, I'm simply creating a function to return a DWORD. My DLL

Pinning a delegate within a struct before passing to unmanaged code

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 05:14:08
问题 I'm trying to use an unmanaged C dll for loading image data into a C# application. The library has a fairly simple interface where you pass in a struct that contains three callbacks, one to receive the size of the image, one that receives each row of the pixels and finally one called when the load is completed. Like this (C# managed definition): [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public struct st_ImageProtocol { public

The Symbol file MyFile.pdb does not match the module

删除回忆录丶 提交于 2019-12-24 02:58:05
问题 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 to debug through it. However, when I try to (explicitly, via the Call Stack) load the symbols, I get the dreaded "The symbol file MyFile.pdb does not match the

Embedded Unmanaged DLLs don't load in ASP.NET

杀马特。学长 韩版系。学妹 提交于 2019-12-24 02:47:11
问题 I'm working on an ASP.NET host for a WCF service. The service references a C++/CLI wrapper library, which itself references an unmanaged DLL. Based on this question I've embedded the unmanaged DLL in the ASP.NET DLL. I then extract it like this: string[] dlls = new [] { "myDLL.dll", "myDLLD.dll" }; Assembly assembly = Assembly.GetExecutingAssembly(); string location = Path.GetDirectoryName(assembly.Location); Dictionary<string, Stream> streams = (from dll in dlls select new KeyValuePair

What purpose do unmanaged.dll.manifest files serve?

拈花ヽ惹草 提交于 2019-12-24 01:16:08
问题 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 would be to load dependent managed assemblies and/or the CLR) What other useful information can these files contain? Would they contain any links to dependent

Calling unmanaged dll from C#. Take 2

爱⌒轻易说出口 提交于 2019-12-24 01:09:50
问题 I have written a c# program that calls a c++ dll that echoes the commandline args to a file When the c++ is called using the rundll32 command it displays the commandline args no problem, however when it is called from within the c# it doesnt. I asked this question to try and solve my problem, but I have modified it my test environment and I think it is worth asking a new question. Here is the c++ dll #include "stdafx.h" #include "stdlib.h" #include <stdio.h> #include <iostream> #include

Reverse PInvoke and create a full unmanaged C# program

隐身守侯 提交于 2019-12-23 19:51:16
问题 I know this is a strange question but the idea is simple: I prefer C# syntax rather than C++: -Setters and getters directly inside a property -interfaces -foreach statement -possibility to declare an implicit cast operator other small things... What I really don't know is if is possible to import a c++ dll (expecially std libraries) in C# if I don't use any namespace (even System) The idea is just to write a program using everything that you will normally use in C++ (nothing from CLR so),

How much GCHandle pinned memory/objects would make Garbage Collector slows down?

假如想象 提交于 2019-12-23 15:09:55
问题 I'm sure this answer will depends the user machine, but there must be some best practices on pinning data . I need to hold like 5 arrays of bytes containing 1.048.576 bytes each. Normally I would prefer to use GCHandle (managed) memory, but some people says it would slow down the GC. I know that can happen, but how much memory/objects need to be pinned to start to really affect the GC? Here are the options that I have: GCHandle.Alloc GCHandleType.Pinned (managed). It will slow down GC??