Pergunta

Eu consegui remendar uma implementação adequada de um jogo de amostra em F # com XNA. No entanto, quando eu tento instanciar minha classe jogo derivado, o código lança uma exceção FileNotFound tentando acessar o Microsoft.Xna.Framework montagem. Por que isso acontece?

Código:

#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()

Eu adicionei as referências apropriadas pelo caminho. Edit: depois de alguma exploração, eu descobri que o meu # projeto F está sendo compilado para 64 bits, o que não funciona com os dlls XNA 32 bits. No entanto VS 2010 does not deixe-me mudar a plataforma de solução. Como faço para corrigir isso?

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top