There was an error validating the extension: System.BadImageFormatException:

There was an error validating the extension: System.BadImageFormatException:

  
Hi,

I'm having problems publishing an extension, and I have this error:

There was an error validating the extension: System.BadImageFormatException: Could not load file or assembly 'file:///C:\Windows\TEMP\BuzgPCjSakWb1fxCjNaYNg\Source\NET\Bin\OutSystems.NssMicrosoftTranslatorAPI.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
File name: 'file:///C:\Windows\TEMP\BuzgPCjSakWb1fxCjNaYNg\Source\NET\Bin\OutSystems.NssMicrosoftTranslatorAPI.dll'
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at OutSystems.HubEdition.ServerCommon.Extensions.ExtensionValidator.CheckExtensionConsistency(String temporaryXIFPath, String temporaryResourcesDirPath, String compoundTypesXml)

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].

I added the extension, can anyone help?

Thanks,
Pedro
 
Hi Pedro,

Does the extension compile on Visual Studio? What is the target Framework?

Cheers
Hi André,

In Visual Studio I do not have errors and targer Framework is 3.5

Thanks

Hi Pedro,

The error explicitly says "This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded". I checked and the dll inside the extension is actually built with .net 4.0, even though the project looks correctly configured.

To solve your problem try editing the MicrosoftTranslatorAPI.csproj final manually and change the ToolsVersion="2.0" to ToolsVersion="4.0"
This can be caused by a Visual Studio 2010 bug that creates assemblies in the wrong version. I mention it in this post, it's the "side-effect" of the warning CS1685 that I talk about.

Regards,
João Rosado



Hi João,

Your solution worked.

Thanks.
Pedro Coelho