Avoid BadImageFormatException with Unmanaged Code

I have a web service that throws a BadImageFormatException when trying to start the service from Visual Studio. This answer to another question suggested running peverify against a DLL to find out if there are any problems. Although my web service DLL is fine, the web service depends on the ILMerged assembly, which has errors:

[IL]: Error: [C: \ blah \ MyILMergedAssembly.dll: Encryption

Utils.SecureStringExtensions :: SecureEquals] [offset 0x00000055] [unmanaged pointer found] [expected unmanaged pointer] Unexpected type on the stack.

[IL]: Error: [C: \ blah \ MyILMergedAssembly.dll: Encryption

Utils.SecureStringExtensions :: SecureEquals] [offset 0x0000005D] [unmanaged pointer found] [expected unmanaged pointer] Unexpected type on the stack.

[IL]: Error: [C: \ blah \ MyILMergedAssembly.dll: Encryption

Utils.SecureStringExtensions :: SecureEquals] [offset 0x0000007E] Unmanaged pointers cannot be verified.

3 Error Check. \ MyILMergedAssembly.dll

(188 Warnings)

I think this is due to the use of Marshaland IntPtrin MyILMergedAssembly, but all I'm doing this, I have a method that is declared unsafe. How can I get rid of the errors that peverify gives and hopefully get rid of the BadImageFormatException exception that appears when I try to start my web service?

: , ILMerge . - DLL MyILMergedAssembly, BadImageFormatException. . peverify , :

[IL]: : [C:\blah\Connection.dll:

.ConnectionBase::. ctor] [HRESULT 0x80070002] - .

ConnectionBase, , Connection.dll, , , , / Connection. " " " ". ConnectionBase, , internal.

: " " -, DLL . compilerOptions="/unsafe" Web.config - system.codedom > compilers > compiler node. -:

"" . .

+3
1

, , . , 32/64- VS, ILMerge. Enable 32-Bit Applications True IIS 7 ( Windows 7 64-). - . .

+1

All Articles