To run this application, you first must install .N

2019-06-16 06:30发布

问题:

I have a wpf project that I created in VS2012, but am now trying to hack in VS2010.

In the csproj file I removed the 'required version' stuff. I can open the project in VS2010, I can compile it too, but if I try to run it, I get the 'needs v4.5' message.

I tried removing all the references and adding them back in again: still compiles (so all the dependencies should be on my (XP) machine).

Where else should I be looking?

回答1:

Check the <supportedRuntime> element in your .config file.

If it's set to <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> then it will be looking for .NET 4.5. (And, of course, this setting isn't used at all during compilation, which is why VS won't be issuing any warnings or errors about it when you compile)



回答2:

You need to change the Target Framework set in the Project properties.

If all else fails, then just create a new solution with a WPF application project and add all the cs files and everything else from your other solution and try then.



回答3:

Visual Studio 2012 has a different Runtime than 2010 and different .Net framework, whicle VS2010 uses 4.0 the VS2012 uses 4.5.

Maby this could be helpful: Can Visual Studio 2012 be installed side-by-side w/ Visual Studio 2010?



回答4:

Try changing in web.config file:

<configuration>
    <system.web>
        <compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
    </system.web>
</configuration>

For more details