XNA Creators Club Online
Page 1 of 1 (8 items)
Sort Posts: Previous Next

XNA and F#

Last post 11/19/2009 9:40 PM by johdex. 7 replies.
  • 11/18/2009 6:21 PM

    XNA and F#

    Hi,

    I have been working on a game using F# for some time. Things stopped working on the XBox when I upgraded F# to the October 2009 CTP. The problem is being discussed on HubFS, but I thought I might also ask here.

    Building an F# assembly to use in an XNA game on the XBox used to be easy: Adding references to the XNA assemblies for XBox to the F# project would do it, as long as one did not need anything specific to the XBox (e.g. SetProcessorAffinity()).

    That no longer works. I now get an exception when the game enters the F# code:

    An unhandled exception of type 'System.TypeLoadException' occurred in Unknown Module.

    Additional information: La version de l'assembly System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089 ne peut pas être chargée par cette version du Microsoft .NET Compact Framework.

    I understand that the XBox refuses to load any System.dll other than its own, but how come I am getting this error only now, with the new version of F#?
  • 11/18/2009 7:00 PM In reply to

    Re: XNA and F#

    I am not that familar with F# so call this somewhat of a guess - however the error seems to mention that the type you are trying to load is not supported by the .NET compact framework.  So if nothing in your code changed, it seems that the compiled F# dll is now depending on a resource that is not within the compact framework.

    Again it is somewhat a shot in the dark as I am not familiar with the F# at all - but figured I would at least throw that out there...

    good luck figuring it out, be interested to hearing how you fixed it when you get it working again!

  • 11/18/2009 7:02 PM In reply to

    Re: XNA and F#

    It appears that your version of F# for the compact framework targets a different System.dll than the Xbox expects.
  • 11/18/2009 10:56 PM In reply to

    Re: XNA and F#

    Pfo Cubed:
    It appears that your version of F# for the compact framework targets a different System.dll than the Xbox expects.

    I am not linking against the compact framework. I am following grammerjack's approach.
    Linking against the compact framework may be a solution though, I'll try that. It's not trivial, though as the F# plugin for visual studio does not support that. It should not be too hard to do using a batch script or a makefile.
  • 11/19/2009 12:17 AM In reply to

    Re: XNA and F#

    You do realize that approach is from 2006, right? There's nothing to guarantee a newer version will work the same way.
    Jim Perry - Microsoft XNA MVP
    If people spent a minute searching the forums and reading the FAQs before posting I'd be out of a job.
      Got some XNA Game Studio/XNA Framework development info to share with the community? Put it on the XNA Wiki.
        Please mark posts as Answers or Good Feedback when appropriate.
  • 11/19/2009 3:52 PM In reply to

    Re: XNA and F#

    If you are only getting problems on Xbox, then linking against the compact framework is definitely worth a shot.  Xbox only uses compact framework.
  • 11/19/2009 8:44 PM In reply to

    Re: XNA and F#

    Answer
    Reply Quote
    The Xbox has its own version of the compact framework, with unique strong names. Why not reference the Xbox 360 reference assemblies, which are provided to you? You'll find mscorlib.dll, system.dll, system.xml.dll, and system.core.dll alongside the XNA Framework assemblies.
    Stephen Styrchak | XNA Game Studio Developer
  • 11/19/2009 9:40 PM In reply to

    Re: XNA and F#

    Stephen Styrchak:
    The Xbox has its own version of the compact framework, with unique strong names. Why not reference the Xbox 360 reference assemblies, which are provided to you? You'll find mscorlib.dll, system.dll, system.xml.dll, and system.core.dll alongside the XNA Framework assemblies.


    Thanks, that worked. I had to call the F# compiler directly, though. Using msbuild just ignored the paths I indicated for the standard assemblies (System.dll, System.Core.dll, FSharp.Core.dll).
    The command line I used:
    "C:\Program Files\FSharp-1.9.7.8\\bin\fsc.exe" -o:obj\Release\XBox360.dll --standalone --noframework --define:TRACE --optimize+ --tailcalls+ -r:"C:\Program Files\FSharp-1.9.7.8\CompactFramework\2.0\bin\FSharp.Core.dll" -r:"C:\Program Files\Microsoft XNA\XNA Game Studio\v3.1\References\Xbox360\Microsoft.Xna.Framework.dll" -r:"C:\Program Files\Microsoft XNA\XNA Game Studio\v3.1\References\Xbox360\mscorlib.dll" -r:"C:\Program Files\Microsoft XNA\XNA Game Studio\v3.1\References\Xbox360\System.Core.dll" -r:"C:\Program Files\Microsoft XNA\XNA Game Studio\v3.1\References\Xbox360\System.dll" --target:library --warn:3 --warnaserror:76 --fullpaths --flaterrors <your F# source files here>

    Note that I had to use FSharp.Core.dll built for the compact framework 2.0. If there are differences between the XBox and PC versions of the compact framework, surprising bugs may show up.
Page 1 of 1 (8 items) Previous Next