dllimport

After SQLite update: Unable to find an entry point named 'sqlite3_changes_interop' in DLL 'SQLite.Interop.dll'

不打扰是莪最后的温柔 提交于 2019-12-18 05:39:05
问题 My C#/SQLite was working fine until I decided to update the SQLite DLLs (from 1.0.82.0 to 1.0.84.0). Now I get this crash: Unable to find an entry point named 'sqlite3_changes_interop' in DLL 'SQLite.Interop.dll' A first chance exception of type 'System.EntryPointNotFoundException' occurred in System.Data.SQLite.dll System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft

Where to put DllImport?

こ雲淡風輕ζ 提交于 2019-12-18 04:45:16
问题 static class Class { public static void methodRequiringStuffFromKernel32() { // code here... } } Where do I put [DllImport("Kernel32.dll")] here? 回答1: You put it on the method you're importing from Kernel32.dll. For example, static class Class { [DllImport("Kernel32.dll")] static extern Boolean Beep(UInt32 frequency, UInt32 duration); public static void methodRequiringStuffFromKernel32() { // code here... Beep(...); } } From @dtb: Note that the class should be named NativeMethods ,

DllImport - PreserverSig and SetLastError attributes

喜你入骨 提交于 2019-12-18 04:12:13
问题 On the MSDN I've found the following description for the two attributes: PreserveSig Set the PreserveSig field to true to directly translate unmanaged signatures with HRESULT or retval values; set it to false to automatically convert HRESULT or retval values to exceptions. By default, the PreserveSig field is true. SetLastError Enables the caller to use the Marshal.GetLastWin32Error API function to determine whether an error occurred while executing the method. In Visual Basic, the default is

DllImport - PreserverSig and SetLastError attributes

ぐ巨炮叔叔 提交于 2019-12-18 04:12:09
问题 On the MSDN I've found the following description for the two attributes: PreserveSig Set the PreserveSig field to true to directly translate unmanaged signatures with HRESULT or retval values; set it to false to automatically convert HRESULT or retval values to exceptions. By default, the PreserveSig field is true. SetLastError Enables the caller to use the Marshal.GetLastWin32Error API function to determine whether an error occurred while executing the method. In Visual Basic, the default is

urlmon.dll FindMimeFromData() works perfectly on 64bit desktop/console but generates errors on ASP.NET

不羁岁月 提交于 2019-12-18 04:03:22
问题 I am creating a library of utilities to be used both in desktop environment in a web environment. It contains several features that I believe are often repeated in my applications, including utility to get the mime type of a file by its content (not the extension). The files that I'll have to check are the most common (jpg, png, pdf, txt) so I chose to use the external method FindMimeFromData (link above) Using .NET, how can you find the mime type of a file based on the file signature not the

Call function from DLL?

自闭症网瘾萝莉.ら 提交于 2019-12-18 03:03:29
问题 I'm new to C# and I'm trying to learn to usage of DLLs. I'm trying to wrap my objects in a DLL, and then use it in my program. public class Foo // its in the DLL { public int ID; public void Bar() { SomeMethodInMyProgram(); } } So I try to pack this to a DLL but I can't, because compiler doesn't know what the SomeMethodInMyProgram() is. I would like to use it like: class Program // my program, using DLL { static void Main(string[] args) { Foo test = new Foo(); test.Bar(); } } 回答1: Add the DLL

C# Marshalling double* from C++ DLL?

ⅰ亾dé卋堺 提交于 2019-12-18 02:41:29
问题 I have a C++ DLL with an exported function: extern "C" __declspec(dllexport) double* fft(double* dataReal, double* dataImag) { [...] } The function calculates the FFT of the two double arrays (real and imaginary) an returns a single double array with the real an imaginary components interleaved: { Re, Im, Re, Im, ... } I'm not sure how to call this function in C#. What I'm doing is: [DllImport("fft.dll")] static extern double[] fft(double[] dataReal, double[] dataImag); and when I test it

Calling C DLL from C#

拜拜、爱过 提交于 2019-12-18 01:16:30
问题 I am trying to call a C DLL from C#, but I'm not having any joy. The documentation for the DLL provides an example function delaration for VB that looks like; Declare Function TransGeogPt Lib "c:\DLLS\GDAit.dll" (ByVal sGridFile As String, ByVal lDirection As Long, ByVal dLat As Double, ByVal dLong As Double, pdLatNew As Double, pdLongNew As Double, pdLatAcc As Double, pdLongAcc As Double) As Long Declare Function TransProjPt Lib "c:\DLLS\GDAit.dll" (ByVal sGridFile As String, ByVal

Calling C DLL from C#

China☆狼群 提交于 2019-12-18 01:16:22
问题 I am trying to call a C DLL from C#, but I'm not having any joy. The documentation for the DLL provides an example function delaration for VB that looks like; Declare Function TransGeogPt Lib "c:\DLLS\GDAit.dll" (ByVal sGridFile As String, ByVal lDirection As Long, ByVal dLat As Double, ByVal dLong As Double, pdLatNew As Double, pdLongNew As Double, pdLatAcc As Double, pdLongAcc As Double) As Long Declare Function TransProjPt Lib "c:\DLLS\GDAit.dll" (ByVal sGridFile As String, ByVal

DllImport vs Declare in VB.NET

最后都变了- 提交于 2019-12-17 23:12:47
问题 I notice in the MSDN documentation that there are multiple ways to declare a reference to a function in an external DLL from within a VB.NET program. The confusing thing is that MSDN claims that you can only use the DllImportAttribute class with Shared Function prototypes "in rare cases", but I couldn't find the explanation for this statement, while you can simply use the Declare keyword instead. Why are these different, and where would I appropriately use each case? 回答1: Declare is really an