Reputation: 1597
So I'm trying to build a program that accesses Etsy's API and so far all I am trying to do is make a call to it using OAuth and it throws this exception.
'The invocation of the constructor on type 'testEtsy.MainWindow' that matches the specified binding constraints threw an exception.' Line number '3' and line position '9'.
Here is my XAML
<Window x:Class="testEtsy.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid></Grid>
And here is my code in the MainWindow.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace testEtsy
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
string[] orderNumbers = System.IO.File.ReadAllLines(@"F:\ordernumbers.txt");
public static void getOAuthKey()
{
string ConsumerKey = "q6uqzk27z2yw4tl5s4qerdtp";
string ConsumerSecret = "tkjz2mu4x1";
OAuth.Manager m = new OAuth.Manager();
m["consumer_key"] = ConsumerKey;
m["consumer_secret"] = ConsumerSecret;
OAuth.OAuthResponse requestToken =
m.AcquireRequestToken("https://openapi.etsy.com/v2/oauth/request_token?scope=transactions_r", "POST");
}
}
}
Any help would be greatly appreciated.
Upvotes: 4
Views: 35218
Reputation: 622
The target of your project may not be the same as the target of a third party library. Just as a quick test, change your Platform target (under Project -> Properties -> Build) to x86. If that works, check that any external libs you have are 64 bit otherwise just build everything x86 instead of "Any CPU". For me the culprit was WebsocketSharp, for you looks like the OAuth library?
Upvotes: 4
Reputation: 754725
The most likely of the exception is the following field initializer
string[] orderNumbers = System.IO.File.ReadAllLines(@"F:\ordernumbers.txt");
This code will run as a part of the MainWindow
constructor. If an exception occurs while reading the file this will propragate out of the constructor and cause initialization to fail. The most likely cause is that this file doesn't exist or is inaccessible
Upvotes: 12