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

Winforms content loading with XNA 3.1

Last post 8/17/2009 11:31 AM by Erik Bongers. 2 replies.
  • 8/15/2009 2:47 PM

    Winforms content loading with XNA 3.1

    Hi,

    I'm trying to use the content runtime loading example with XNA 3.1.
    I started with the 3.0 version (which worked fine).

    For 3.1, what should I change?

    I've already replaced the following:
    const string xnaVersion = ", Version=3.1.0.0, PublicKeyToken=b03f5f7f11d50a3a"; //...

    msBuildProject.AddNewImport(

    "$(MSBuildExtensionsPath)\\Microsoft\\XNA Game Studio\\v3.1\\Microsoft.Xna.GameStudio.ContentPipeline.targets", null);

     

    My (relevant) references are :
    Microsoft.Build.Engine : 2.0
    Microsoft.Build.Framework : 2.0
    Microsoft.Xna.Framework : 3.5

    I currently get the error : "Cannot autodetect which importer to use[...]There are no importers which handle this filetype.[...]"
    Thanks in advance!

    Erik. 

  • 8/17/2009 11:12 AM In reply to

    Re: Winforms content loading with XNA 3.1

    Nevermind, I found the solution here ... on this forum :)
    What I actually tried was implement the XNB creation and loading into an XNA 3.1 project, not a winforms project.

    To implement this solution in a XNA 3.1 project do the following.

    1. Add the following two references and make sure to pick the correct versions:
    * Microsoft.Build.Engine, version 2.0
    * Microsoft.Build.Framework, version 2.0

    2. From the example project to load content (version 3.0!), that you find here, copy these 3 files to your own project:
    ContentBuilder.cs
    ErrorLogger.cs
    App.config
     (I created these files in my project with Add->New Item, and then only copied the content.)

    3. In the ContentBuilder.cs file, change the following 3 lines. (basically you just change the version numbers to 3.1):

    const string xnaVersion = ", Version=3.1.0.0, PublicKeyToken=6d5c3888ef60e27d";     
    msBuildProject.SetProperty("XnaFrameworkVersion""v3.1");     
    msBuildProject.AddNewImport("$(MSBuildExtensionsPath)\\Microsoft\\XNA Game Studio\\v3.1\\Microsoft.Xna.GameStudio.ContentPipeline.targets"null);  

    4. Copy the LoadModel() method from the MainForm.cs file in the example project.
    I changed this method to use the standard Game.Content to load the model.
    For the standard content manager to find the generated XNB files, the ContentBuilder must place the XNB files in the my_project\bin\x86\Debug\Content folder. To do this, change the outputPath string in the ContentBuilder.CreateBuildProject to my_project\bin\x86\Debug. The model will then be created in the Content subfolder.

    That's it. Just call the LoadModel() function to load a model.

    Notice that this solution still uses the v2.0 build engine. I may try add a post on getting this to work with the 3.5 version as well (I read a post on this somewhere).
    If that works, you'll read about this in the next reply.

     

  • 8/17/2009 11:31 AM In reply to

    Re: Winforms content loading with XNA 3.1

    As promised, the solution for using the .Net 3.5 version of the build engine.

    Do the same as above but in step 1, add the references to the 3.5 versions of the Build.Engine and Build.Framework assemblies.

    You need to add one extra file <my_application_name>.exe.config.
    Set the file property "Copy to output directory" to "Copy if newer", so it will end up next to your exe file.
    Fill this config file with the following code:

    <?xml version="1.0" ?> 
    <configuration> 
      <runtime> 
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
          <dependentAssembly> 
            <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>  
            <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="3.5.0.0"/>  
          </dependentAssembly> 
          <dependentAssembly> 
            <assemblyIdentity name="Microsoft.CompactFramework.Build.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>  
            <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="9.0.0.0"/>  
          </dependentAssembly> 
        </assemblyBinding> 
      </runtime> 
    </configuration> 
     

    That's it.
Page 1 of 1 (3 items) Previous Next