Question

I managed to cobble together a suitable implementation of a sample game in F# with xna. However when i try to instantiate my derived game class, the code throws a FileNotFound exception trying to access the Microsoft.Xna.Framework assembly. Why does this happen?

Code:

#light
open System
open Microsoft.Xna.Framework
open Microsoft.Xna.Framework.Audio
open Microsoft.Xna.Framework.Content
open Microsoft.Xna.Framework.Design
open Microsoft.Xna.Framework.GamerServices
open Microsoft.Xna.Framework.Graphics
open Microsoft.Xna.Framework.Input

type SampleGame() as self =
    class
    inherit Game()
    let mutable manager : GraphicsDeviceManager = null
    let mutable spriteBatch : SpriteBatch = null
    do
        manager <- new GraphicsDeviceManager(self)
    override Game.Initialize() = 
        base.Initialize()
    override Game.LoadContent() = 
        spriteBatch <- new SpriteBatch(manager.GraphicsDevice)
        base.LoadContent()
    override Game.Update(gameTime) = 
        base.Update(gameTime)
        if GamePad.GetState(PlayerIndex.One).Buttons.Back = ButtonState.Pressed then
            self.Exit()
    override Game.Draw(gameTime) = 
        manager.GraphicsDevice.Clear(Color.CornflowerBlue);
        base.Draw(gameTime)
    end

let game = new SampleGame()
game.Run()

I have added the proper references by the way. Edit: after some exploration, i found that my F# project is being compiled to 64 bit, which does not work with the 32 bit XNA dlls. However VS 2010 doesnt let me change the solution platform. How do i fix this?

Was it helpful?

Solution

I don't know enough about XNA, but is it 'in the GAC', or do you need to copy the XNA dlls next to your .exe? It sounds like perhaps having Microsoft.Xna.Framework.dll next to your .exe may solve it.

EDIT

Based on the 32/64-bit info, perhaps manually change the "<Platform>" in the .fsproj file. (Right click the project, 'Unload Project', then right click again and 'Edit Whatever.fsproj', poke the XML to have 'x86' (rather than 'x64' or 'AnyCPU') as the Platform value, save, and right click project and 'Reload'.) (Various F# bugs in Beta1 conspire to make the Platform/SolutionConfiguration-experience less than optimal.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top