dllimport

Error: function definition is marked dllimport

半腔热情 提交于 2019-12-22 11:27:33
问题 I'm attempting to get a toy program running with AVT's VIMBA SDK. At the moment, it is going well save for one caveat. When I attempt to compile, I get a series of errors (14 of them) that all are marked same thing: function *insert call here* definition is marked dllimport The file itself is below- the curious thing is that in in this file, only ~IFeatureObserver(), IFeatureObserver(), and IFeatureObserver( const IFeatureObserver& ) are triggering the error; FeatureChanged() does not error

Reload a DLL which has been imported with DllImport

只谈情不闲聊 提交于 2019-12-22 05:04:56
问题 My C# application (.NET Framework 4.0) imports an external unmanaged DLL with the following code: [DllImport("myDLL.dll"), EntryPoint="GetLastErrorText"] private static extern IntPtr GetLastErrorText(); Unfortunately there seems to be a bug in the third-party DLL. As a workaround I would need to unload the DLL and reload it afterwards. How can I do this? I've seen several posts but they all talk about managed DLLs. 回答1: You can write a wrapper around the library that manages the access to it.

Reload a DLL which has been imported with DllImport

孤街浪徒 提交于 2019-12-22 05:04:09
问题 My C# application (.NET Framework 4.0) imports an external unmanaged DLL with the following code: [DllImport("myDLL.dll"), EntryPoint="GetLastErrorText"] private static extern IntPtr GetLastErrorText(); Unfortunately there seems to be a bug in the third-party DLL. As a workaround I would need to unload the DLL and reload it afterwards. How can I do this? I've seen several posts but they all talk about managed DLLs. 回答1: You can write a wrapper around the library that manages the access to it.

Explanation about high-resolution performance counter and its existence related to .NET Stopwatch?

假如想象 提交于 2019-12-22 03:54:17
问题 Inside the static Stopwatch constructor we can see the following code, that basicly checks whether a high-resolution performance counter exists. static Stopwatch() { if (!SafeNativeMethods.QueryPerformanceFrequency(out Frequency)) { IsHighResolution = false; Frequency = 0x989680L; tickFrequency = 1.0; } else { IsHighResolution = true; tickFrequency = 10000000.0; tickFrequency /= (double) Frequency; } } On MSDN it says about QueryPerformanceFrequency : Retrieves the frequency of the high

Interop with native libraries in linux

限于喜欢 提交于 2019-12-21 04:31:27
问题 I am writing an application in C#, which is cross platform. It uses DllImport for several different libraries. It is also both x32 and x64. It seems to work right for my own compiled .dll/.so. I put the x32 shared libraries in the x32 sub-folder, and the x64 shared libraries in the x64 sub-folder. On windows via .net framework I call SetDllDirectory("x32" or "x64") depending on the current runtime. On mono, either through windows, linux or mac, I use a DllMap , in RandomLibrary.dll.config. It

Trying to create a Math Input Panel in C#

让人想犯罪 __ 提交于 2019-12-21 02:45:25
问题 How do I create a Math Input Panel in C#? I have tried to put it into a dll and call it but it just closes right away. #include <stdafx.h> #include <atlbase.h> #include "micaut.h" #include "micaut_i.c" extern "C" __declspec(dllexport) int run() { CComPtr<IMathInputControl> g_spMIC; // Math Input Control HRESULT hr = CoInitialize(NULL); hr = g_spMIC.CoCreateInstance(CLSID_MathInputControl); hr = g_spMIC->EnableExtendedButtons(VARIANT_TRUE); hr = g_spMIC->Show(); return hr; } I call the dll

How to use method from VB6 dll in .NET?

落花浮王杯 提交于 2019-12-21 02:38:08
问题 I have ActiveX VB6 DLL (have no access to its sources), and want to call method 'GetUnitInfo' I use to import it like: [DllImport(@"C:\Users\R\Documents\lab.dll")] public static extern long GetUnitInfo(String strRequest, String strInfo, String strName); But I get an exception: Unable to find an entry point named 'GetUnitInfo' in DLL Also I have tryied to load it: Assembly myAssembly ; myAssembly = Assembly.LoadFile("C:\\Users\\R\\Documents\\lab.dll"); but getting an exception The module was

C#: Access 32-bit/64-bit DLL depending on platform

筅森魡賤 提交于 2019-12-21 02:33:13
问题 we use a self-written 32bit C++ DLL from our C# applications. Now we've noticed that when the C# applications are run on a 64bit system, the 64bit runtime is automatically used and of course the 32bit DLL can not be accessed from the 64bit runtime. My question is: is there a way of using the 32bit DLL? If not, if I created a 64bit version of the DLL, would it be easily possible to let the application choose which one to P/Invoke to? I'm thinking of creating two helper classes in C#: One that

Error C2491: Function declared in header and defined in C++

久未见 提交于 2019-12-20 04:20:07
问题 I have been trying to build a device adapter for a open-source software called Micro-manager to control a microscope and there are some problems that I am facing, there are these two files (one header and the other CPP) that are already present in the open source package of Micro-Manager. //MoudluleInterface.h #ifndef _MODULE_INTERFACE_H_ #define _MODULE_INTERFACE_H_ #ifdef WIN32 #ifdef MODULE_EXPORTS #define MODULE_API __declspec(dllexport) #else #define MODULE_API __declspec(dllimport)

DLL Get Symbols From Its Parent (Loader)

北城以北 提交于 2019-12-20 03:07:24
问题 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? 回答1: (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