0

I'm using the following code to open a file and then trying to write something to it:

public partial class MainWindow : Window
{
    StreamWriter file = null;
    public MainWindow()
    {
        InitializeComponent();
        using (file = new StreamWriter("../data/floorPlane.txt", true))
        {
            file.WriteLine("x \t y \t z \t w \n");
        }
    }
}

But it always gives the following error:

A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

Additional information: 'The invocation of the constructor on type 'SkeletalViewer.MainWindow' that matches the specified binding constraints threw an exception.

I'm totally new to c#. Maybe the question is kindof stupid.

Thanks,

Ondrej Janacek
  • 12,486
  • 14
  • 59
  • 93
Fihop
  • 3,127
  • 9
  • 42
  • 65

2 Answers2

0

First, check the inner exception to see what you are actually messing up. Then, if the answer is still not apparent, compare your code to the sample found at this MSDN article: http://msdn.microsoft.com/en-us/library/vstudio/system.io.streamwriter

GEEF
  • 1,175
  • 5
  • 17
0

this exception is caught many times. You can press ctrl+alt+E to check all exception and than you can find real exception.