Search code examples
c#exceptionxna

Can't use FileFormatException (?)


I'm currently writing a custom importer for my small XNA project and am trying to do something as simple as throwing a FileFormatException in my importer Import method.

I have referenced WindowsBase.dll, so FileFormatException should be available under System.IO in IntelliSense, right? I type System.IO and there is no autocomplete with FileFormatException under System.IO.

Here is where the throw statement is located:

namespace TetrominoImporter
{
    public class TetrominoReader : ContentImporter<Tetromino>
    {
        public const string blockFileName = "blocks.txt";

        public override Tetromino Import(string filename, ContentImporterContext context)
        {
            // HERE

Solution

  • You need to include WindowsBase in your references, as FileFormatException is defined within that assembly. Once you've added that, you should be able to resolve System.IO.FileFormatException