0

I'm writing a MapEditor in winform with embeded XNA. And my biggest problem is whenever I try to load any file with the ContentManager, it only reads .XNB files.

I wanted to read an effect file like this:

effect = contentManager.Load<Effect>("Effect2");

But then I get the error that "Effect2.xnb doesn't exists". And if I add "Effect2.fx" it still give me error with the message "Effect2.fx.xnb doesn't exists" :\

I have no idea what to do. I saw a solution by set the content properties. But I cannot set those properties in this case,because it's a winform application.

Does anyone have a great idea or anything?

Edit!

Solution found!

I implemented the ContentBuilder from this example with writing a few helper methods for dynamic loading: http://create.msdn.com/en-US/education/catalog/sample/winforms_series_2

Beardminator
  • 784
  • 8
  • 20

1 Answers1

1

You'll have to add an XNA Content project, and include your content in that project. All of those files will be compiled/processed into individual XNB files, which you'll be able to load. Just make sure to reference that project in your WinForms project.

The same rules apply for a Game project: It still needs an accompanying Content project.

EDIT:

Ahh, right... you want to load them dynamically. For that, you'll need to ensure that any computer that tries to use your map editor will have the XNA development framework installed. Then you'll need to process the files manually before loading them with the ContentManager... not entirely sure how to do this.

EDIT:

Take a look at this post for more information about loading unprocessed content at runtime: How do I load a texture in XNA at runtime?

Community
  • 1
  • 1
cwharris
  • 17,835
  • 4
  • 44
  • 64
  • In these 2 minutes i actually thought about this too :D thanks for the answer ! i try it out! – Beardminator Jun 16 '12 at 20:49
  • shameless plug... Use Krypton XNA for Dynamic 2D lighting ;) – cwharris Jun 16 '12 at 20:54
  • 2
    @user1461097 Please, don't hesitate to answer your own question, if the answer is different to this. Other people also want to know how you got it working. – annonymously Jun 17 '12 at 00:58
  • I implemented the ContentBuilder from this example with writing a few helper methods for dynamic loading: http://create.msdn.com/en-US/education/catalog/sample/winforms_series_2 – Beardminator Jun 17 '12 at 07:35