Class Library to be Shared by XNA Platforms
What is the difference between Windows/Xna/Phone/Standard library?
I assume that each one has access to platform specific API. Is it possible to create a common denominator class library that has access to neither of the API, but in return works on all platforms?
I tried creat开发者_C百科ing a standard c# class library targeted against 4.0 (client profile) that only references standard mscorlib and System. This works in a windows XNA project, but gives the following error in an Xbox XNA project:
Warning 3 The primary reference "Qua.Game, Version=1.3.3.30456, Culture=neutral, processorArchitecture=MSIL" 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 "Qua.Game, Version=1.3.3.30456, Culture=neutral, processorArchitecture=MSIL" or retarget your application to a framework version which contains "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
Is it possible to create a common denominator class library that has access to neither of the API, but in return works on all platforms?
Yes, there are some new tools to allow you to do this - the Portable Library Tools.
Almost everyone agrees that the current situation is a bit of a mess...
There is a new project underway for improved Portable libraries - currently under CTP - see http://visualstudiogallery.msdn.microsoft.com/b0e0b5e9-e138-410b-ad10-00cb3caf4981/
Portable Library Tools is a new Visual Studio add-in from Microsoft that enables you to create C# and Visual Basic libraries that run on a variety of .NET-based platforms without recompilation.
It claims that this project will assist with all of:
XNA, Silverlight, .NET, portable, Windows Phone, Xbox 360
Hopefully it's a good step in the right direction!
Use XNA Game Studio's built-in "Create Copy for Xbox 360" and "Create Copy for Windows Phone 7" functionality (documented here).
These work for both game projects and libraries and will keep the projects in-sync across all platforms.
精彩评论