Как заставить Visual Studio 2010 использовать .NET 4.0 вместо .NET 2.0 в проекте Windows Phone? - PullRequest
3 голосов
/ 22 июля 2011

Это проект Windows Phone 7.

По какой-то странной причине Visual Studio 2010 не позволяет мне установить целевую версию .NET на .NET 4.0 в настройках проекта, вкладка «Приложение».Он затенен.

Когда я компилирую проект, сборки XNA - это .NET 4.0, но System и System.Core и все остальные - .NET 2.0.

Когда я говорю «Добавить ссылку», это не позволяет мне выбирать какие-либо системные сборки .NET 4.0, например mscorlib.

Я удалил .NET 4.0, а затем переустановил его.Никакой помощи.

Редактировать: Моя конечная цель - заставить это скомпилировать.Почему он выбирает .NET 2.0 для системных сборок?

Редактировать: Я получаю следующие ошибки:

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

Редактировать: ОК, я удалил эти оскорбительные сборки XNAОказалось, что они мне не нужны.Теперь компилятор вернулся к этой ошибке:

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

Compile complete -- 1 errors, 0 warnings

Ответы [ 3 ]

5 голосов
/ 22 июля 2011

Visual Studio показывает правильные сборки. Невозможно выбрать сборки .NET 4.0 для Windows Phone 7 по той простой причине, что в Windows Phone 7 не работает .NET 4.0.

Версии, которые вы видите, должны быть такими:

  • Microsoft.Phone. * - 7.0.0.0
  • Microsoft.XNA. * - 4.0.0.0
  • mscorelib - 2.0.5.0
  • Система. * - 2.0.5.0
1 голос
/ 22 июля 2011

Windows Phone использует Silverlight (Silverlight 3 для 7.0, Silverlight 4 для Mango), который не использует полную версию .NET CLR, но использует подмножество полной версии .NET CLR (см. Ссылки MSDN в Silverlight в Windows Телефон , Silverlight Architecture ). Поэтому вы не можете загружать сборки .NET 4.0 или даже полные сборки .NET 2.0.

Номера версий 2.0.5.0, которые вы видите, являются специальными номерами версий Silverlight - на самом деле это не полные сборки .NET 2.0.

Однако это означает, что вы можете добавить некоторые сборки Silverlight в Windows Phone (например, это то, что вы делаете для платформы Silverlight Unit Test). Если вы сделаете это, вы получите предупреждение, что не все настольные Silverlight поддерживаются в Windows Phone. Вы должны делать это только с осторожностью, так как все может сломаться ...

0 голосов
/ 22 июля 2011

Пожалуйста, проверьте, используете ли вы .NET Framework или клиентский профиль .NET Framework.Если это профиль клиента, измените его обратно на .NET Framework.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...