Downloading your own DLL (32-bit) in the operating wmi provider (32-bit) on a 64-bit OS

I am working on an internal wmi provider that loads its own third-party library using [DllImport]. The dll location is tied to c: \ mydllpath. Before loading the dll, I set the current directory to the dll loaction in the provider Bind () method.

Environment.CurrentDirectory = Environment.ExpandEnvironmentVariables ("% SystemDrive%") + "\ mydllpath";

The provider is built for "any processor" installed using gacutil and installexe.

gacutil.exe / if myprovider.dll

installutil.exe myprovider.dll

It works great on all 32-bit Windows platforms. But on a 64-bit platform (with Windows 64-bit) it does not work when I test WMIC. But when I tested with the WMI code creator, it worked fine.

After debugging, I found that it throws the following error.

System.BadImageFormatException Additional Information: An attempt was made to load a program with the wrong format. (Exception from HRESULT: 0x8007000B)

After searching for help from the Internet, it was proposed to create a provider for x86. But the provider built with x86 gives another error, for example ...

ERROR: Code = 0x80041013 Description = Provider loading failed Facility = WMI

I also tried to load my own DLLs (actually 2 dlls and sys file) using the / linkref command line, but failed because of the inability to load the sys file using / linkref.

# , . , 64- .

!

+3
2

64 ? , Visual Studio # 32- , 32- DLL . 64- .

.NET .net IL . , ​​ " ", 64 64- 32- 32- .

32- ( x86), 32 64- , 32- DLL.

UPDATE: , WMI . , 64- 64- ( , ). , .. .

UPDATE2: , -, , WMI 64- 64- , " ", , , 32- .

+3

, . ( , ) 64 , 32- DLL .

- ,

+1

All Articles