dllimport

DllImport Unmanaged, Non .NET Dll to .NET Project Representing Char * and Void __StdCall

末鹿安然 提交于 2019-12-01 22:58:31
I have a DLL non .net and unmanaged written in Borland C++ that I need to import. It returns void and has the identifier __stdcall on the function. It also requires passing of char *. When I try to add it as a reference to my project in VS 2005, it returns an error of not valid assembly. How can I do this in C#? This what I currently have and it does not work: [DllImport ("Project1.dll", CallingConvention=CallingConvention.StdCall)] public static extern IntPtr CustomerForm (String caption); For an unmanaged DLL you do not add it as a reference. Make sure the binary DLL is located in the same

DLL Get Symbols From Its Parent (Loader)

五迷三道 提交于 2019-12-01 22:50:12
I am porting a program to MS Windows. This program uses dynamically loaded plugins. The plugins reference symbols in the main program. I cannot even get the DLLs past the linker without all symbols being resolved. Is there a way to solve this? (Sorry, I'd like to ask for clarification in a comment but I'm too much of a newbie to be allowed.) When you say the plugins "reference symbols in the main program", is it about referencing functions or data? Also, what language/compiler are you using? Assuming it's only about functions, and in C/C++: it's possible to export a function from a .EXE as if

DllImport vs LoadLibrary, What is the best way?

可紊 提交于 2019-12-01 22:42:17
i'm usually using Win32 API in c#.NET. But not declare all in one application. Sometimes usually using user32, sometimes gdi32 ... I think when i declare all api function, those use lot of memory. What is the best way using API in .NET ? Most of the Win32 API is available through managed abstractions. Otherwise, declare the ones you need using DllImport . LoadLibrary should really only be used where you have provided alternate functionality, that is, your application can work even without that particular API function. If the API function is critical, using DllImport will let the loader worry

Unresolved external symbol _declspec(dllimport)

巧了我就是萌 提交于 2019-12-01 21:38:42
I've created an DLL for my Console Application in Visual Studio. In my DLL I have a Class named Dialog_MainMenu with has a *.cpp file and a *.h file. Following error message : Error 9 error LNK2001: unresolved external symbol "__declspec(dllimport) public: static enum Dialog_MainMenu::GAME_STATES Dialog_MainMenu::CurrentGameState" (_ imp ?CurrentGameState@Dialog_MainMenu@@2W4GAME_STATES@1@A) C:\Users\Kevin\Desktop\c++ projects\development_testing\The Intense Adventure\Dialogs\Dialog_MainMenu.obj Dialogs Which I kinda don't understand. This only occured when I added an enum to my prototype in

calling C++ functions containing callbacks in C#

吃可爱长大的小学妹 提交于 2019-12-01 20:53:43
问题 hey all im trying to get my head around calling this c++ function in c#: BOOL __stdcall CodecStart(int hRadio,void __stdcall (*CallbackFunc)(void *),void *CallbackTarget); this is from a WinRadio api found here http://www.winradio.com/home/g305_sdk.htm. i did find that other people asked about calling this specific function on the net and they had: public delegate void CallbackFunc( IntPtr p); [DllImport("WRG305API.dll")] public static extern bool CodecStart(int hRadio, CallbackFunc func,

definition of dllimport function not allowed

守給你的承諾、 提交于 2019-12-01 20:17:53
While compiling a C code, I'm getting the following error: c:\users\kbarman\documents\mser\vlfeat-0.9.13-try\mser\stringop.c(71): error C2491: 'vl_string_parse_protocol' : definition of dllimport function not allowed In the file stringop.c, I have the following function: VL_EXPORT char * vl_string_parse_protocol (char const *string, int *protocol) { char const * cpt ; int dummy ; /* handle the case prot = 0 */ if (protocol == 0) protocol = &dummy ; /* look for :// */ cpt = strstr(string, "://") ; if (cpt == 0) { *protocol = VL_PROT_NONE ; cpt = string ; } else { if (strncmp(string, "ascii",

Why does a .NET program survive a corrupt stack? (when using the wrong calling convention)

自古美人都是妖i 提交于 2019-12-01 16:22:58
In VS2010, the managed debugging assistant will give you a pInvokeStackImbalance exception ( pInvokeStackImbalance MDA ) if you call a function using the wrong calling convention, commonly because you didn't specify CallingConvention = Cdecl when calling a C library. E.g. you wrote [DllImport("some_c_lib.dll")] static extern void my_c_function(int arg1, int arg2); instead of [DllImport("some_c_lib.dll", CallingConvention=CallingConvention.Cdecl)] static extern void my_c_function(int arg1, int arg2); and thus got the StdCall calling convention instead of Cdelc. If you answer this, you already

Why does a .NET program survive a corrupt stack? (when using the wrong calling convention)

假如想象 提交于 2019-12-01 15:15:34
问题 In VS2010, the managed debugging assistant will give you a pInvokeStackImbalance exception (pInvokeStackImbalance MDA) if you call a function using the wrong calling convention, commonly because you didn't specify CallingConvention = Cdecl when calling a C library. E.g. you wrote [DllImport("some_c_lib.dll")] static extern void my_c_function(int arg1, int arg2); instead of [DllImport("some_c_lib.dll", CallingConvention=CallingConvention.Cdecl)] static extern void my_c_function(int arg1, int

C# DllImport library written on C++

£可爱£侵袭症+ 提交于 2019-12-01 14:15:59
I'm pretty new in C#. I have Dll written on C++ by myself and I'm going to use functions from that dll in C# app. So, I do the following when declare functions in C++ project: public static __declspec(dllexport) int captureCamera(int& captureId); Then I'm trying to import this method in C# app: [DllImport("MyLib.dll")] public static extern int captureCamera(ref int captureId); But I have the exception: Unable to find an entry point named 'captureCamera' in DLL 'MyLib.dll'. The task is to do dllimport without specifying EntryPoint parameter. Could anyone help me? You are defining a C++ function

How to import caffe module in Python?

混江龙づ霸主 提交于 2019-12-01 13:48:08
I have build .dll of _caffe.cpp on Windows (Release, x64). I changed extension .dll to .pyd and trying to import it in python: import caffe File "\caffe-master\python\caffe\__init__.py", line 1, in <module> from .pycaffe import Net, SGDSolver File "\caffe-master\python\caffe\pycaffe.py", line 13, in <module> from ._caffe import Net, SGDSolver ImportError: DLL load failed: The specified module could not be found. What does it mean, some module of dependencies missing which was included in project in Visual Studio, where I build this dll? You need to add Python Caffe to PYTHONPATH. For example: