jjzjj

dllimport

全部标签

c# - 缺少 DLLImport,即使有 "using InteropServices"

我有以下代码:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Runtime.InteropServices;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingMapsApp.DB;namespaceMapsApp{publicpartialclass_Default:System.Web.UI.Page{[DLLImport("GeoUrbanApp.exe")]publicstaticexter

c# - 缺少 DLLImport,即使有 "using InteropServices"

我有以下代码:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Runtime.InteropServices;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingMapsApp.DB;namespaceMapsApp{publicpartialclass_Default:System.Web.UI.Page{[DLLImport("GeoUrbanApp.exe")]publicstaticexter

c# - 从 DLL 调用函数?

我是C#新手,正在尝试学习DLL的使用。我试图将我的对象包装在一个DLL中,然后在我的程序中使用它。publicclassFoo//itsintheDLL{publicvoidBar(){SomeMethodInMyProgram();}}所以我尝试将其打包到DLL中,但我做不到,因为编译器不知道SomeMethodInMyProgram()是什么。我想像这样使用它:classProgram//myprogram,usingDLL{staticvoidMain(string[]args){Footest=newFoo();test.Bar();}} 最佳答案

c# - 从 DLL 调用函数?

我是C#新手,正在尝试学习DLL的使用。我试图将我的对象包装在一个DLL中,然后在我的程序中使用它。publicclassFoo//itsintheDLL{publicvoidBar(){SomeMethodInMyProgram();}}所以我尝试将其打包到DLL中,但我做不到,因为编译器不知道SomeMethodInMyProgram()是什么。我想像这样使用它:classProgram//myprogram,usingDLL{staticvoidMain(string[]args){Footest=newFoo();test.Bar();}} 最佳答案

c# - 加载 32 位 DLL 时出现 BadImageFormatException,目标是 x86

我有一个肯定是32位的DLL(FreeType)(header:IMAGE_FILE_MACHINE_I386)。我想在C#代码中使用它,使用DllImport。我的应用程序的目标是x86,IntPtr.Size是4,进程是32位。但是我得到BadImageFormatException(来自HRESULT的异常:0x8007000B)。有什么问题?当然我用的是64位的Windows7。 最佳答案 据我了解,专为x86构建并在64位操作系统中运行的程序集只能加载为x86构建的库,否则将抛出BadImageFormatExceptio

c# - 加载 32 位 DLL 时出现 BadImageFormatException,目标是 x86

我有一个肯定是32位的DLL(FreeType)(header:IMAGE_FILE_MACHINE_I386)。我想在C#代码中使用它,使用DllImport。我的应用程序的目标是x86,IntPtr.Size是4,进程是32位。但是我得到BadImageFormatException(来自HRESULT的异常:0x8007000B)。有什么问题?当然我用的是64位的Windows7。 最佳答案 据我了解,专为x86构建并在64位操作系统中运行的程序集只能加载为x86构建的库,否则将抛出BadImageFormatExceptio

c# - 在 C# DllImport 中使用 32 位或 64 位 dll

情况是这样的,我在我的dot.net应用程序中使用基于C的dll。有2个dll,一个是32位版本,名为MyDll32.dll,另一个是64位版本,名为MyDll64.dll。有一个静态变量保存DLL文件名:stringDLL_FILE_NAME。它的使用方式如下:[DllImport(DLL_FILE_NAME,CallingConvention=CallingConvention.Cdecl,EntryPoint=Func1")]privatestaticexternintis_Func1(intvar1,intvar2);到目前为止很简单。如您所想,该软件是在“任何CPU”开启的情

c# - 在 C# DllImport 中使用 32 位或 64 位 dll

情况是这样的,我在我的dot.net应用程序中使用基于C的dll。有2个dll,一个是32位版本,名为MyDll32.dll,另一个是64位版本,名为MyDll64.dll。有一个静态变量保存DLL文件名:stringDLL_FILE_NAME。它的使用方式如下:[DllImport(DLL_FILE_NAME,CallingConvention=CallingConvention.Cdecl,EntryPoint=Func1")]privatestaticexternintis_Func1(intvar1,intvar2);到目前为止很简单。如您所想,该软件是在“任何CPU”开启的情

c - 在 linux 中获取导出函数的名称和地址

通过使用PIMAGE_DOS_HEADER,我可以从Windows中的可执行文件中获取导出的函数名称和指针列表。API(example)。Linux的等效API是什么?对于上下文,我正在创建单元测试可执行文件,并且我正在导出以名称“test_”开头的函数,我希望可执行文件在运行时旋转并执行所有测试函数。示例伪代码:intmain(intargc,char**argv){autorun=new_trun();automodule=dlopen(NULL);autoexports=get_exports(module);//length;i++){autoexport=exports[i]

c - 在 linux 中获取导出函数的名称和地址

通过使用PIMAGE_DOS_HEADER,我可以从Windows中的可执行文件中获取导出的函数名称和指针列表。API(example)。Linux的等效API是什么?对于上下文,我正在创建单元测试可执行文件,并且我正在导出以名称“test_”开头的函数,我希望可执行文件在运行时旋转并执行所有测试函数。示例伪代码:intmain(intargc,char**argv){autorun=new_trun();automodule=dlopen(NULL);autoexports=get_exports(module);//length;i++){autoexport=exports[i]