如何使Visual Studio 2010中使用.NET 4.0,而不是.NET 2.0在Windows Phone项目? [英] How to make Visual Studio 2010 use .NET 4.0 instead of .NET 2.0 on a Windows Phone project?

查看:422
本文介绍了如何使Visual Studio 2010中使用.NET 4.0,而不是.NET 2.0在Windows Phone项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一款Windows Phone 7项目。

由于一些奇怪的原因,Visual Studio 2010中不会让我设定的目标.NET版本.NET 4.0中的项目设置,应用程序选项卡。它变灰。

当我编译项目,XNA的组件是.NET 4.0,但系统和System.Core程序和所有其余的都是.NET 2.0。

当我说添加引用,它不会让我选择任何.NET 4.0的系统组件一样的mscorlib。

我卸载了.NET 4.0,然后重新安装它。没有帮助。

编辑:我的终极目标是让这个编译。为什么选择.NET 2.0的系统组件?

编辑:我收到这些错误:

  C:\ WINDOWS \ Microsoft.NET \框架\ v4.0.30319 \ Microsoft.Common.targets(1360,9):警告MSB3268:主要参考Microsoft.Xna.Framework 。视频无法得到解决,因为它的框架组件的间接依赖mscorlib程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089,它无法在当前的目标框架内解决。 .NETFramework,版本= V4.0,外形=客户。要解决此问题,要么删除提及Microsoft.Xna.Framework.Video或重新定位你的应用程序的框架版本,其中包含mscorlib程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089。
C:\ WINDOWS \ Microsoft.NET \框架\ v4.0.30319 \ Microsoft.Common.targets(1360,9):警告MSB3268:主要参考Microsoft.Xna.Framework.Net无法得到解决,因为它有一个间接的依赖于框架组件mscorlib程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089,它无法在当前的目标框架内解决。 .NETFramework,版本= V4.0,外形=客户。要解决此问题,要么删除提及Microsoft.Xna.Framework.Net或重新定位你的应用程序的框架版本,其中包含mscorlib程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089。
C:\ WINDOWS \ Microsoft.NET \框架\ v4.0.30319 \ Microsoft.Common.targets(1360,9):警告MSB3268:主要参考Microsoft.Xna.Framework.Avatar无法得到解决,因为它有一个间接的依赖于框架组件mscorlib程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089,它无法在当前的目标框架内解决。 .NETFramework,版本= V4.0,外形=客户。要解决此问题,要么删除提及Microsoft.Xna.Framework.Avatar或重新定位你的应用程序的框架版本,其中包含mscorlib程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089。
C:\ WINDOWS \ Microsoft.NET \框架\ v4.0.30319 \ Microsoft.Common.targets(1360,9):警告MSB3268:主要参考Microsoft.Xna.Framework.Storage无法得到解决,因为它有一个间接的依赖于框架组件mscorlib程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089,它无法在当前的目标框架内解决。 .NETFramework,版本= V4.0,外形=客户。要解决此问题,要么删除提及Microsoft.Xna.Framework.Storage或重新定位你的应用程序的框架版本,其中包含mscorlib程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089。
C:\ WINDOWS \ Microsoft.NET \框架\ v4.0.30319 \ Microsoft.Common.targets(1360,9):警告MSB3268:主要参考Microsoft.Xna.Framework.Xact无法得到解决,因为它有一个间接的依赖于框架组件mscorlib程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089,它无法在当前的目标框架内解决。 .NETFramework,版本= V4.0,外形=客户。要解决此问题,要么删除提及Microsoft.Xna.Framework.Xact或重新定位你的应用程序的框架版本,其中包含mscorlib程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089。
C:\ WINDOWS \ Microsoft.NET \框架\ v4.0.30319 \ Microsoft.Common.targets(1360,9):警告MSB3268:主要参考Microsoft.Xna.Framework.Net无法得到解决,因为它有一个间接的依赖框架组装系统,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089,它无法在当前的目标框架内解决。 .NETFramework,版本= V4.0,外形=客户。要解决此问题,要么删除提及Microsoft.Xna.Framework.Net或重新定位你的应用程序,其中包含系统,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089的框架版本。
C:\ WINDOWS \ Microsoft.NET \框架\ v4.0.30319 \ Microsoft.Common.targets(1360,9):警告MSB3268:主要参考Microsoft.Xna.Framework.Xact无法得到解决,因为它有一个间接的依赖框架组装系统,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089,它无法在当前的目标框架内解决。 .NETFramework,版本= V4.0,外形=客户。要解决此问题,要么删除提及Microsoft.Xna.Framework.Xact或重新定位你的应用程序的框架版本,其中包含系统,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089。
C:\ WINDOWS \ Microsoft.NET \框架\ v4.0.30319 \ Microsoft.Common.targets(1360,9):警告MSB3268:主要参考Microsoft.Xna.Framework.Xact无法得到解决,因为它有一个间接的依赖于框架组件System.Core程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089,这可能无法在当前的目标框架解决。 .NETFramework,版本= V4.0,外形=客户。要解决此问题,要么删除提及Microsoft.Xna.Framework.Xact或重新定位你的应用程序,其中包含System.Core程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089的框架版本。
C:\ WINDOWS \ Microsoft.NET \框架\ v4.0.30319 \ Microsoft.Common.targets(1360,9):警告MSB3268:主要参考Microsoft.Xna.Framework.Xact无法得到解决,因为它有一个间接的依赖于框架组件Microsoft.VisualC,版本= 10.0.0.0,文化=中性公钥= b03f5f7f11d50a3a,它无法在当前的目标框架内解决。 .NETFramework,版本= V4.0,外形=客户。要解决此问题,要么删除提及Microsoft.Xna.Framework.Xact或重新定位你的应用程序,其中包含Microsoft.VisualC,版本= 10.0.0.0,文化=中性公钥= b03f5f7f11d50a3a的框架版本。
 

编辑:确定,我删除了这些问题的XNA组件。原来,我并不需要他们。现在的编译器是回到这个错误:

 错误CS0518:predefined类型'System.Object的'未定义或导入

编译完成 -  1错误,0警告
 

解决方案

Visual Studio是显示出你正确的组件。你不能选择的原因很简单,Windows Phone 7的不运行.NET 4.0 .NET 4.0组件为Windows Phone 7。

您看到的版本应该是这样的:

  • Microsoft.P​​hone * - 7.0.0.0
  • Microsoft.XNA * - 4.0.0.0
  • mscorelib - 2.0.5.0
  • 在系统* - 2.0.5.0

This is a Windows Phone 7 project.

For some strange reason, Visual Studio 2010 will not let me set the target .NET version to .NET 4.0 in the project settings, Application tab. It's grayed out.

When I compile the project, the XNA assemblies are .NET 4.0, but System and System.Core and all the rest are .NET 2.0.

When I say "Add Reference", it won't let me select any of .NET 4.0 system assemblies like mscorlib.

I uninstalled .NET 4.0 and then reinstalled it. No help.

Edit: My ultimate goal is to get this to compile. Why is it choosing .NET 2.0 for the System assemblies?

Edit: I'm getting these errors:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3268: The primary reference "Microsoft.Xna.Framework.Video" could not be resolved because it has an indirect dependency on the framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0,Profile=Client". To resolve this problem, either remove the reference "Microsoft.Xna.Framework.Video" or retarget your application to a framework version which contains "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3268: The primary reference "Microsoft.Xna.Framework.Net" could not be resolved because it has an indirect dependency on the framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0,Profile=Client". To resolve this problem, either remove the reference "Microsoft.Xna.Framework.Net" or retarget your application to a framework version which contains "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3268: The primary reference "Microsoft.Xna.Framework.Avatar" could not be resolved because it has an indirect dependency on the framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0,Profile=Client". To resolve this problem, either remove the reference "Microsoft.Xna.Framework.Avatar" or retarget your application to a framework version which contains "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3268: The primary reference "Microsoft.Xna.Framework.Storage" could not be resolved because it has an indirect dependency on the framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0,Profile=Client". To resolve this problem, either remove the reference "Microsoft.Xna.Framework.Storage" or retarget your application to a framework version which contains "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3268: The primary reference "Microsoft.Xna.Framework.Xact" could not be resolved because it has an indirect dependency on the framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0,Profile=Client". To resolve this problem, either remove the reference "Microsoft.Xna.Framework.Xact" or retarget your application to a framework version which contains "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3268: The primary reference "Microsoft.Xna.Framework.Net" could not be resolved because it has an indirect dependency on the framework assembly "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0,Profile=Client". To resolve this problem, either remove the reference "Microsoft.Xna.Framework.Net" or retarget your application to a framework version which contains "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3268: The primary reference "Microsoft.Xna.Framework.Xact" could not be resolved because it has an indirect dependency on the framework assembly "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0,Profile=Client". To resolve this problem, either remove the reference "Microsoft.Xna.Framework.Xact" or retarget your application to a framework version which contains "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3268: The primary reference "Microsoft.Xna.Framework.Xact" could not be resolved because it has an indirect dependency on the framework assembly "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0,Profile=Client". To resolve this problem, either remove the reference "Microsoft.Xna.Framework.Xact" or retarget your application to a framework version which contains "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3268: The primary reference "Microsoft.Xna.Framework.Xact" could not be resolved because it has an indirect dependency on the framework assembly "Microsoft.VisualC, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0,Profile=Client". To resolve this problem, either remove the reference "Microsoft.Xna.Framework.Xact" or retarget your application to a framework version which contains "Microsoft.VisualC, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".

Edit: OK, I removed those offending XNA assemblies. It turned out that I didn't need them. Now the compiler is back to this error:

error CS0518: Predefined type 'System.Object' is not defined or imported

Compile complete -- 1 errors, 0 warnings

解决方案

Visual Studio is showing you the correct assemblies. You cannot select .NET 4.0 assemblies for Windows Phone 7 for the simple reason that Windows Phone 7 doesn't run .NET 4.0.

The versions you see should be like this:

  • Microsoft.Phone.* - 7.0.0.0
  • Microsoft.XNA.* - 4.0.0.0
  • mscorelib - 2.0.5.0
  • System.* - 2.0.5.0

这篇关于如何使Visual Studio 2010中使用.NET 4.0,而不是.NET 2.0在Windows Phone项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆