I’m trying to develop a cross platform application.
Currently I have set up following solutions, with their platform specified template:
- GameBase
- Windows
- Xbox
- WindowsPhone
The Windows, Xbox and WindowsPhone uses the GameBase as reference, but I want to separate different code for each platform used in the GameBase library as the example below:
#if WINDOWS
graphics.PreferredBackBufferWidth = 640;
graphics.PreferredBackBufferHeight = 480;
graphics.ApplyChanges();
#elif WINDOWS_PHONE
TargetElapsedTime = TimeSpan.FromTicks(333333);
InactiveSleepTime = TimeSpan.FromSeconds(1);
#endif
It does not work, and I can see that in the Configuration Manager, that GameBase’s platform is Any CPU, so I wonder if it has anything to due with the GameBase being a Class Library?
If so how do I fix it, and if possible I would like to keep the #if tags.
Directory setup | Windows Solution Game.cs | Solution Explorer

You have to create separate Visual Studio projects for the different platforms. You can reuse code across multiple projects by adding the source using Add As Link. Within a shared source file that is linked to multiple project you can use
#ifetc. to separate platform specific code.How “It does not work” is not clear from your question but in general you cannot build an assembly (e.g. class library) for Windows and then use it on XBox and Windows Phone.