XamlParseException in PresentationFramework.dll when calling FileHelperEngine constructor

gus picture gus · Aug 1, 2013 · Viewed 23.2k times · Source

A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: 'The invocation of the constructor on type 'filehelpertest.MainWindow' that matches the specified binding constraints threw an exception.' Line number '3' and line position '9'.

Hi all,

I am new to FileHelpers.

I made a minimal WPF project in VS Express 2013 in order to isolate this problem. The code is copied from their "Quick Start for Delimited files" section in the FileHelpers docs.

I have tried referencing the 3 different versions of FileHelpers.dll (2.0, 1.1, Mono1.2), and I have tried rebooting. But there is no effect that I can see. There must be something really simple I'm missing right?

Or does FileHelpers not work for newer versions of .NET?

Thanks!

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using FileHelpers;

namespace filehelpertest
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            FileHelperEngine engine = new FileHelperEngine(typeof(Customer));
            // To Read Use:
            Customer[] res = engine.ReadFile("f1.txt") as Customer[];
            // To Write Use:
            engine.WriteFile("f2.txt", res);
        }

        [DelimitedRecord(",")]  
        public class Customer
        {
            public int CustId;
            public string Name;
        }
    }
}

Answer

gus picture gus · Aug 5, 2013

The solution to my problem is same as the accepted answer at XAML Parse Exception - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

I did CTRL-ALT-E then checked everything. Now the pop-up window shows the actual exception rather than xamlparseexception.