TwitterCredentials.CreateCredentials initialisation exception

Mar 20, 2014 at 12:21 PM
Hi,

Code that was working in 0.9.0.2 is now not working 0.9.0.7:
TwitterCredentials.Credentials = TwitterCredentials.CreateCredentials(twitter_AccessToken, twitter_AccessSecret, twitter_ConsumerKey, twitter_ConsumerSecret);
It generates this error:
An unhandled exception of type 'System.TypeInitializationException' occurred
Additional information: The type initializer for 'Tweetinvi.TwitterCredentials' threw an exception.
I've ensured all the variables have values, and I've tried with two different sets of twitter credentials. Both sets of credentials worked before, as did the code. This line is also the first real bit of code run in my app.

Should I be doing this a different way in the new version?

Thanks,
Craig
Coordinator
Mar 20, 2014 at 12:25 PM
Hi,

No you should not, I will have a look during lunch break or tonight.

Linvi
Mar 20, 2014 at 12:39 PM
Thanks for quick reply Linvi.

For completeness, I've noticed I now get this warning at build time:
1>  No way to resolve conflict between "Microsoft.Practices.Unity, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "Microsoft.Practices.Unity, Version=2.1.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35". Choosing "Microsoft.Practices.Unity, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" arbitrarily.
1>  Consider app.config remapping of assembly "Microsoft.Practices.Unity, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "2.1.505.0" [] to Version "3.0.0.0" [C:\Users\Craig\Documents\Visual Studio 2012\Projects\App\packages\Unity.3.0.1304.1\lib\Net45\Microsoft.Practices.Unity.dll] to solve conflict and get rid of warning.
1>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly.
I was hoping nuget would manage all the dependencies etc. Have I inadvertently got the "wrong" Unity.dll included?
Coordinator
Mar 20, 2014 at 1:18 PM
Did you used nuget to get the package?

Linvi
Mar 20, 2014 at 1:25 PM
Yes, I started with blank project, and only used nuget to add Tweetinvi, which also added the dependencies automatically. I'm using no other manually added references.

nuget Tweetinvi dependencies list Unity as >= 2.1.505.2, whereas after auto updates, I now have Unity 3.0.1304.1
Coordinator
Mar 20, 2014 at 11:41 PM
Hi Craigae,

I have tried everything I could and I have not been able to get Unity updated to 3.0.
Which version of Visual Studio are you using because I only have VS 2013 currently?

I have tried direct install and update from 0.9.0.2 to latest 0.9.0.7 for Console and WPF projects.
  • .NET Framework 4.0
  • .NET Framework 4.5
  • .NET Framework 4.5.1
Either you were very unlucky or I am not doing the same thing as you did.
Please keep up to date.

Linvi
Mar 21, 2014 at 12:02 PM
Thanks for looking into this. I've pasted the help->about system info below. In the meantime, I'll try and downgrade my Unity and see if that helps (seems like it will).

Craig

Microsoft Visual Studio Express 2012 for Windows Desktop
Version 11.0.61030.00 Update 4
Microsoft .NET Framework
Version 4.5.50709

Installed Version: Desktop Express

Team Explorer for Visual Studio 2012 05695-004-0030004-02640
Microsoft Team Explorer for Visual Studio 2012

Visual Basic 2012 05695-004-0030004-02640
Microsoft Visual Basic 2012

Visual C# 2012 05695-004-0030004-02640
Microsoft Visual C# 2012

Visual C++ 2012 05695-004-0030004-02640
Microsoft Visual C++ 2012

NuGet Package Manager 2.8.50126.400
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

SQL Server Data Tools 11.1.20828.01
Microsoft SQL Server Data Tools
Jun 25, 2014 at 9:50 AM
I am having the same error here is its screen shotImage


please help me out :/
Jun 26, 2014 at 3:54 PM
I forgot to update this to say downgrading Unity fixed my problem.

However, that looks like a different error to the one I received, waqarm22. I'm not very experienced with VS/C# errors, but that looks like it's looking for a file that isn't there? The first thing I'd try and do would be delete all the usings, and only add in the ones you really need. Also, you might have accidentally added a reference to your project that doesn't exist any more.
Coordinator
Jun 30, 2014 at 8:02 PM
Hello there,

Please update to the latest version of Tweetinvi. The latest versions do not use Unity anymore. It now uses Autofac which enables Tweetinvi to be working as a cross platform solution.

Regards,
Linvi