WCF Service: Adding a reference results in: System.BadImageFormatException

I have a Solution with a WCF Service Project, a few Classes in projects and a Winform Project. When trying to add a Service Reference from within the Winform Project i always got the Microsoft WCF Service Host – ‘System.BadImageFormatException: Could not load file or assembly ‘file’.. Logo Microsoft Visual Studio

An explanation or better, a direction I’ve found at Atalasoft Knowledgebase Q10165.

I just changed the Platform target from x86 to Any CPU, recompiled both projects in the solution and since then, i can add a service reference. Who knows why.. you? drop me a mail/comment!

Error Message i got:

System.BadImageFormatException: Could not load file or assembly ‘file:///D:\Development\WCFTestService.SQL.2010\Media.Manager.SQL.Services.WCF\bin\Debug\Media.Manager.SQL.Services.WCF.exe’ or one of its dependencies. An attempt was made to load a program with an incorrect format.
File name: ‘file:///D:\Development\WCFTestService.SQL.2010\Media.Manager.SQL.Services.WCF\bin\Debug\Media.Manager.SQL.Services.WCF.exe’
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Microsoft.Tools.SvcHost.ServiceHostHelper.LoadServiceAssembly(String svcAssemblyPath)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Leave a Reply

Your email address will not be published. Required fields are marked *