XamlParseException in PresentationFramework.dll when calling the FileHelperEngine constructor

The first random exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional Information: "Calling the constructor of type 'filehelpertest.MainWindow', which matches the specified binding constraints made an exception." Line number "3" and line position "9".

Hello everybody,

I am new to FileHelpers.

I did a minimal WPF project in VS Express 2013 to isolate this issue. The code is copied from the Quick Start for Split Files section in FileHelpers documents.

I tried to reference 3 different versions of FileHelpers.dll (2.0, 1.1, Mono1.2), and I tried to restart. But I do not see any effect. Something must be really simple, I have no right 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; } } } 
+4
source share
2 answers

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

I did CTRL-ALT-E, then checked everything. Now the popup shows the actual exception, not xamlparseexception.

+14
source

I think the problem is with the path, provides the full path to the engine, and uses a general example:

  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); } } } 
+1
source

Source: https://habr.com/ru/post/1494723/


All Articles