我正在使用Xna 3.0(使用C#4.0)并在SharpDevelopPortable中编译空白模板时出现此错误:
System.IO.FileLoadException: Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
at Test_XNA.Game1..ctor()
at Test_XNA.Program.Main() in c:\Users\%username%\Documents\Stuff\SharpDevelopPortable\Data\SharpDevelop Projects\Test_XNA\Test_XNA\Program.cs:line 9
突出显示:
using System;
namespace Test_XNA
{
static class Program
{
static void Main()
{
Game1 game = new Game1(); // <-- This line is highlighted
game.Run();
}
}
}
重要的是要注意我的Xna版本和C#版本是不同的。此外,我不是管理员,这就是我使用Xna 3.0的原因。我也收到了这个警告:
Found conflicts between different versions of the same dependent assembly. (MSB3247)
虽然我不确定这意味着什么。
任何建议都将不胜感激。
答案 0 :(得分:1)
根据this出色的答案,您必须找到app.config
文件,并将useLegacyV2RuntimeActivationPolicy="true"
属性添加到startup
标记中:
<?xml version="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>