Please help, I've tried everything else I can think of to solve this problem.
And before you respond please note:
I have done everything I can from other questions on StackOverflow.com and else-ware on the web. Such as but not limited to: Changing the build configuration from: "Any CPU" to "x64" and even to "x86". And also changing the target build from .NET 4.0 to .NET 3.5 (This does not work as I am using System.Windows.Interactivity that requires .NET 4.0) So I'm rather stuck with .NET 4.0. So please don't give an answer telling me to do this as I have already tried various combinations of this.
I've got a project in VS2013 called TimersXP that is an open-source project on CodePlex.com: https://timersxp.codeplex.com/
It builds without any errors, but I'm getting a run-time exception: System.BadImageFormatException was unhandled Message: An unhandled exception of type 'System.BadImageFormatException' occurred in Unknown Module. Additional information: Could not load file or assembly 'TimersXP.exe' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
A little history, the project was originally .NET 3.5, but when I found I had to add System.Windows.Interactivity and that had to support .NET 4.0 I bumped up the version number.
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\.NETFramework\v4.0\Libraries\System.Windows.Interactivity.dll</HintPath>
<Private>False</Private>
</Reference>
Yes I know it says version 4.5.0.0. I tried combinations of that as well. unless I missed some combination that works different that what would be expected.
It's open source so all of the code for the project is available, can someone please help me out? I'm afraid I am out of ideas.
Maybe in the App.config file this version number?
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
I don't want to just go through all of the code and change every place it says version to 3.5 or 4.0 or 4.5. That didn't seem like a very good idea.
As usual, once I see it, I'll probably want to kick myself!
It is strange that in my case, my project properties was already showing up as 4.5.2 but my app.config was still showing the runtime version as 2.0. I right clicked on project > chose project properties > updated target framework to 4.5.1 first and then updated to 4.5.2. That made the trick and updated the app.config as below:
Before:
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
After:
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>