System.BadImageFormatException - cannot solve the problem

I am using Visual Studio 2010 running on Windows 7 X64 I was trying to create a simple implementation of WCF bidirectional communication. Sorry, I got stuck really fast.

I have 3 projects: - Service library with a simple service contract and implementation - ServiceHost: Hosting a service library through SelfHosting - Client: using a method from the WCF service

Something I immediately noticed that the Service library had any processor as a platform. The other two had x86 as a platform. At the moment, I had no idea that I would get this error, so it really didn't bother me.

Then I launched the services library using the built-in wcfsvchost.exe. The service was hosted without problems. Then I wanted to host my service through my own host. Here I got my first experience with System.BadImageFormatException. I had no idea what it was at that moment. So I got stuck and made some kind of search engine. If I understand correctly, the platform of all DLLs, etc. Must be the same. if someone can explain me a little better. Please do.

In any case, thatโ€™s why I would change the service library platform because it had any processor instead of x86. So I tried to do this using Project settings and configuration manager. But the problem is that I did not have the opportunity to change it. Then I unloaded the project, looked at what another .csproj looked like, and changed the values โ€‹โ€‹there. Rebooted it, and everything was in order. Now he had the right platform, x86. So let the test run the service library. BOOM System.BadImageFormatException

System.BadImageFormatException: :///C:\Users\Sven\documents\visual studio 2010\Projects\DuplexDemo\CustomerService2\bin\Debug\CustomerService2.dll . . : ':///C:\Users\Sven\documents\visual studio 2010\Projects\DuplexDemo\CustomerService2\bin\Debug\CustomerService2.dll'   System.Reflection.RuntimeAssembly._nLoad (AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark & stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark & stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)   System.Reflection.Assembly.Load(AssemblyName assemblyRef)   Microsoft.Tools.SvcHost.ServiceHostHelper.LoadServiceAssembly(String svcAssemblyPath)

=== === LOG: = Sven-PC\Sven LOG: -ref . = C:\Users\Sven\\visual studio 2010\Projects\DuplexDemo\CustomerService2\bin\Debug\CustomerService2.dll LOG: Appbase = file:///C:/Users/Sven/documents/visual studio 2010//DuplexDemo/CustomerService2/bin/Debug LOG: Initial PrivatePath = NULL

: ().

LOG: LoadFrom. WRN: LoadFrom. , , Assembly.Load(). LOG: : C:\Users\Sven\documents\visual studio 2010\Projects\DuplexDemo\CustomerService2\bin\Debug\CustomerService2.dll.config LOG: : LOG: C:\Windows\Microsoft.NET\Framework64\v4.0.21006\config\machine.config. LOG: URL:///C:/Users/Sven/documents/visual studio 2010/Projects/DuplexDemo/CustomerService2/bin/Debug/CustomerService2.dll. ERR: (hr = 0x8007000b). .

, , , . , , .

- , ? , , WCF . x32

,

+3
1

, , , 32- ?

, , , , - ?

, , , , , 3- , 64- .

+3

Source: https://habr.com/ru/post/1732032/


All Articles