Search code examples
vb.netdllreferencexna

Could not load file or assembly 'Microsoft.Xna.Framework.Game.dll'


What I'm using: Visual Basic 2008 express edition, XNA version 3.1

So I was trying to learn XNA in VB using this link: http://www.dreamincode.net/forums/topic/239483-using-xna-in-vbnet-part-i/

Naturally after finishing the post, I debugged my project but an error pops up:

FileNotFoundException was unhandled

Could not load file or assembly 'Microsoft.Xna.Framework.Game, Version=3.1.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d' or one of its dependencies. The system cannot find the file specified.

I tried searching the net/this site to see if anyone encountered the same problem, and the closest was this post: Could not resolve this reference error

Tried following what he said (changing DLLs to a different folder/setting copy local to true), but that seemed to spawn another problem:

BadImageFormatException was unhandled

Could not load file or assembly 'Microsoft.Xna.Framework.Game, Version=3.1.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d' or one of its dependencies. An attempt was made to load a program with an incorrect format.

I have no idea where I went wrong, could it be that I'm using VB 2008 express edition and should move to a newer one? (because I read another post stating that by setting .NET framework target to version 4.0, the problem will be solved)


Solution

  • Nevermind about it, turns out I just need to target x86 platform.

    Tools --> Options --> Projects and Solutions-->General. Then Check "Show advanced build configurations"

    Then

    Build --> Configuration manager --> Active Solution Platform --> New --> change "Type or select the new platform" to x86.

    Link that answered my question: https://social.msdn.microsoft.com/Forums/en-US/d4fa83dc-eed1-4ead-96a1-78bbd9ba6d3a/vb-express-target-x86-platform?forum=vblanguage