dllimport

How can I write a signature on C# for a wrapped C++ method having double indirection on its arguments?

自古美人都是妖i 提交于 2020-01-07 02:48:07
问题 I'm writing a wrapper for a dll. The dll has a method whose signature resembles the following: unsigned long aMethod(char **firstParameter, char **secondParameter)) aMethod returns string pointers to all parameters. I've searching at google for a tutorial to give me insight on how to write the signature on C# so the framework can do the marshalling process. How can it be written? Do you know about any tutorial, book or documentation on this subject? 回答1: Not really answering you question but

c++ lnk 2028, lnk 2020, lnk 2019 and lnk 2001 when importing dll

大城市里の小女人 提交于 2020-01-05 19:07:30
问题 A few day ago I asked a similar question, which helped me look in the right direction with __declspec(), but I got stuck again. I'll be as clear as possible. Hopefully someone can tell me what I'm doing wrong. It is probably something small and simple. Projects info: jc: project type: Class Library configuration type: Dynamic Library (.dll) common runtime language support: /clr references: System System.Data System.Drawing System.Windows.Forms System.Xml test (start up project): project type:

Passing C# string Array to C++ DLL and modify it there [duplicate]

自作多情 提交于 2020-01-05 04:20:33
问题 This question already has an answer here : Pass writeable StringBuilder array to C++ from C# (1 answer) Closed 2 years ago . As the title suggests I would like to let a string array be described in a function which is in a C++ DLL. In my actual attempt it runs without exception, but my strArray does not contain any objects after the C++ Function call. My C# Code: var strArray = new StringBuilder[100]; for (int i = 0; i < strArray .Length; i++) { strArray[i] = new StringBuilder(50); }

Keeping PInvoked method alive

孤街浪徒 提交于 2020-01-04 14:37:31
问题 Here's my C code: LIBRARY_API bool __cdecl Initialize(void (*FirstScanForDevicesDoneFunc)(void)); And here's C# PINvoke code to work with this DLL: [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void FirstScanForDevicesDoneFunc(); [DllImport("Native.dll", CallingConvention=CallingConvention.Cdecl)] public static extern bool Initialize(FirstScanForDevicesDoneFunc); When I call this method like this: static public void Init() { Initialize(FirstScanForDevicesDone); } static

Keeping PInvoked method alive

我是研究僧i 提交于 2020-01-04 14:37:23
问题 Here's my C code: LIBRARY_API bool __cdecl Initialize(void (*FirstScanForDevicesDoneFunc)(void)); And here's C# PINvoke code to work with this DLL: [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void FirstScanForDevicesDoneFunc(); [DllImport("Native.dll", CallingConvention=CallingConvention.Cdecl)] public static extern bool Initialize(FirstScanForDevicesDoneFunc); When I call this method like this: static public void Init() { Initialize(FirstScanForDevicesDone); } static

Fortran Dll import

帅比萌擦擦* 提交于 2020-01-04 14:24:47
问题 There is a code in Fortran by Robert L. Parker and Philip B. Stark: FORTRAN subroutine bv(key, m, n, a, b, bl, bu, x, w, act, zz, istate, loopA) implicit double precision (a-h, o-z) ! x is an unknown n-vector ! a is a given m by n matrix ! b is a given m-vector ! bl is a given n-vector of lower bounds on the components of x. ! bu is a given n-vector of upper bounds on the components of x. ! key = 0 ! ---Output parameters: ! x the solution vector. ! w(1) the minimum 2-norm || a.x-b ||. !

Load Library/Module from Memory

元气小坏坏 提交于 2020-01-04 08:15:10
问题 I realized a little C# porting of this application that allows to load libraries from memory/stream instead of using LoadLibrary API function that works through filesystem. After messing around a little bit with pointers and mimatching results... finally I have something working as intended. The only problem I have is that the call to DLLMain always fails (I tried it with Kernel32.dll and User32.dll). I can't understand why and I don't know how to debug the issue. Here is the main function of

SharePoint fails to load a C++ DLL on Windows 2008

匆匆过客 提交于 2020-01-03 11:49:25
问题 I have a SharePoint DLL that does some licensing things and as part of the code it uses an external C++ DLL to get the serial number of the hardisk. When I run this application on Windows Server 2003 it works fine, but on Windows Server 2008 the whole site (loaded on load) crashes and resets continually. This is not Windows Server 2008 R2 and is the same in 64 or 32 bits. If I put a Debugger.Break before the DLL execution then I see the code get to the point of the break and then never come

Difficulties starting JVM in Python using jpype

我是研究僧i 提交于 2020-01-02 08:34:50
问题 I have been using jpype to integrate with some java code using python lately and have been having no real issues. I am now attempting to set up my stack on a new system and am running into difficulties. I am running 32-bit Python 3.6.5 and 32-bit oracle Java 1.8 update 171. Python and jpype have been installed using conda ( conda create -n venv -c conda-forge python jpype1 arrow ), and jpype.getDefaultJVMPath() returns the expected path ( C:\Program Files (x86)\Java\jre1.8.0_171\bin\client

How to call win32 dll in windows 7

≡放荡痞女 提交于 2020-01-02 07:37:14
问题 From within a C# application(Visual Studio 2008) i am calling a win32 dll using DllImport. Everything works fine in Windows XP. However when i use the same exe and dll in Windows 7, the win32 dll fails to get loaded. Do i need to write any extra code to invoke a win32 dll from Windows 7 ? 回答1: Before building the C# program, make sure that in Visual studio Configuration Manager you choose "x86" and not "any CPU" as the platform. If any CPU is selected, your C# application runs as a 64bit