dllimport

DllImport - An attempt was made to load a program with an incorrect format [duplicate]

大城市里の小女人 提交于 2019-11-27 06:54:58
问题 This question already has an answer here: Loading a 32-bit dll in a 64-bit process [duplicate] 1 answer I want my C# application to conditionally run a native method. Deciding at run time whether to run either the x86 or the x64 version of the dll. This question explains how to choose 32 bit or 64 bit at compile time, but that does not help. I want to make the decision at runtime. I'm currently doing the following: [SuppressUnmanagedCodeSecurity] internal static class MiniDumpMethods {

Unload a DLL loaded using DllImport

穿精又带淫゛_ 提交于 2019-11-27 06:54:16
How do I unload a DLL which has been loaded using DllImport in C#? Mitch Wheat The most reliable way to unload an unmanaged DLL from a process that got loaded by a [DllImport] pinvoke declaration is to load it yourself, again, by pinvoking LoadLibrary(). That gives you a reliable handle to the DLL and works correctly even if the module name of the DLL is ambiguous. It doesn't have any affect at runtime, other than the Windows loader increasing the internal reference count on the DLL from 1 to 2. You can then pinvoke FreeLibrary() twice to decrease the reference count to 0, passing it the

Is there any native DLL export functions viewer? [closed]

强颜欢笑 提交于 2019-11-27 06:12:15
Is there any free native Windows DLL export functions viewer, which shows the function name, and a list of their parameters? you can use Dependency Walker to view the function name. you can see the function's parameters only if it's decorated. read the following from the FAQ: How do I view the parameter and return types of a function? For most functions, this information is simply not present in the module. The Windows' module file format only provides a single text string to identify each function. There is no structured way to list the number of parameters, the parameter types, or the return

How to use a class in DLL?

点点圈 提交于 2019-11-27 04:05:37
Can I put a class inside a DLL? The class i wrote is this: class SDLConsole { public: SDLConsole(); ~SDLConsole(){}; void getInfo(int,int); void initConsole(char*, char*, SDL_Surface*, int, int, int); void sendMsg(char*,int, SDL_Surface*); void cls(SDL_Surface*); private: TTF_Font *font; SDL_Surface *consoleImg; int width, pos, height, line, size, ctLine; SDL_Surface* render(char*,int); }; I know how to load a DLL and use the function inside a DLL, but how can I put a class inside a DLL? Thank you very much. If you use run time dynamic linking (uses LoadLibrary to load the dll) you cannot

C++ : inline functions with dllimport/dllexport?

Deadly 提交于 2019-11-27 03:39:18
问题 I create a DLL (say CORE.DLL) ,I have classes/functions declared as follows: #ifdef RINZOCORE_SHARED #define RINZO_LIB __declspec(dllexport) #else #define RINZO_LIB __declspec(dllimport) #endif I have defined many inline functions with "dllexport" macro , class RINZO_LIB CVector { public: CVector();//!< default constructor .. real& x();//!< accessor for the x component (can be used as l-value too) real& y();//!< accessor for the y component (can be used as l-value too) real& z();//!< accessor

Why doesn't .NET find the OpenSSL.NET dll?

天大地大妈咪最大 提交于 2019-11-27 03:32:45
问题 EDIT (the whole question, it was too unclear) I want to use OpenSSL.NET The OpenSSL.NET install instructions page: INSTALL Make sure you have libeay32.dll and ssleay32.dll in the current working directory of your application or in your PATH. DONE In your .NET project, add a reference to the ManagedOpenSsl.dll assembly. DONE I have put libeay32.dll and ssleay32.dll in both my bin/Debug and bin/Release directories. I have also put them in system32 . Here is my FULL code: using System; namespace

Pass multi - dimensional array from managed code to unmanaged code

时间秒杀一切 提交于 2019-11-27 03:26:56
问题 I would like to do the following: Create three dimesinal array in c# code like this: var myArray = new short[x,y,z]; UnanagedFunction(myArray); Pass it to unmanaged code (c++) like this: void UnmanagedFunction(short*** myArray) { short first = myArray[0][0][0]; } UPDATED When I try the following code I have runtime error: Attempted to read or write to protected memory. Thank you!!! 回答1: IntPtr Array3DToIntPtr(short[, ,] Val) { IntPtr ret = Marshal.AllocHGlobal((Val.GetLength(0) + Val

Need to activate a window

左心房为你撑大大i 提交于 2019-11-26 21:04:59
问题 I have a situation like this. I have the window handle of an application. I need to activate it. I tried all these functions but is not working always.(most of the time , it doesn't work the first time and I'll have to manually click on it to activate it. Second attempt onwards it works fine) The reason why I am doing this is because I have code written in the Form.Activate event of the form which I need to execute. Application is a single instance application. When a new instance is created

Using pHash from .NET

我的梦境 提交于 2019-11-26 20:02:17
问题 I am trying to use pHash from .NET First thing I tried was to register (regsvr32) phash.dll and asked here Second of all, i was trying to import using DllImport as shown below. [DllImport(@".\Com\pHash.dll")] public static extern int ph_dct_imagehash( [MarshalAs(UnmanagedType.LPStr)] string file, UInt64 hash); But when i try to access the method above during run-time, following error message shows up. Unable to find an entry point named 'ph_dct_imagehash' in DLL '.\Com\pHash.dll'. What does

PInvokeStackImbalance C# call to unmanaged C++ function

狂风中的少年 提交于 2019-11-26 19:34:38
问题 After switching to VS2010, the managed debug assistant is displaying an error about an unbalanced stack from a call to an unmanaged C++ function from a C# application. The usuals suspects don't seem to be causing the issue. Is there something else I should check? The VS2008 built C++ dll and C# application never had a problem, no weird or mysterious bugs - yeah, I know that doesn't mean much. Here are the things that were checked: The dll name is correct. The entry point name is correct and