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;
}
}
}
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.
I think that the problem is with the path, provide the full path to the engine and use the generic verion like that:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
try
{
var engine = new FileHelperEngine<Customer>();
// To Read Use:
Customer[] res = engine.ReadFile(@"c:\yourpath\f1.txt");
// To Write Use:
engine.WriteFile(@"c:\yourpath\f2.txt", res);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With