problem with 'Tweetinvi.TwitterCredentials

Jun 3, 2015 at 3:36 PM
Hello,
I have developed a windows service using tweetinvi , it was working correctly in my local machine , but once i deployed the service to our server , it had a problem we couldn't solve relating to twwetinvi , an exception occured at the first occurence of SetCredentials , the message is :

The type initializer for 'Tweetinvi.TwitterCredentials' threw an exception.
Topshelf.HostFactory Error: 0 : An exception occurred creating the host, Topshel
f.ServiceBuilderException: An exception occurred creating the service: TwitterSe
rvice ---> System.TypeInitializationException: The type initializer for 'Tweetin
vi.Stream' threw an exception. ---> System.TypeInitializationException: The type
initializer for 'Tweetinvi.TweetinviContainer' threw an exception. ---> System.
TypeLoadException: Method 'AddWebException' in type 'Tweetinvi.Logic.Exceptions.
ExceptionHandler' from assembly 'Tweetinvi.Logic, Version=0.9.7.1, Culture=neutr
al, PublicKeyToken=7247f14397bf67b9' does not have an implementation.
at Tweetinvi.Logic.TweetinviLogicModule.InitializeExceptionHandler()
at Tweetinvi.Logic.TweetinviLogicModule.Initialize()
at Tweetinvi.Injectinvi.AutofacContainer.InitializeModules()
at Tweetinvi.Injectinvi.AutofacContainer.Initialize()
at Tweetinvi.Injectinvi.AutofacContainer..ctor()
at Tweetinvi.TweetinviContainer..cctor()
--- End of inner exception stack trace ---
at Tweetinvi.TweetinviContainer.ResolveT
at Tweetinvi.Stream..cctor()
--- End of inner exception stack trace ---
at Tweetinvi.Stream.CreateFilteredStream()
at TwitterService.TwitterPayment..ctor() in C:\Projets\Smoney\server\ApplisEx
ternes\TwitterServiceV2\ConsoleApplication3\TwitterPayment.cs:line 37
at TwitterService.Worker..ctor() in C:\Projets\Smoney\server\ApplisExternes\T
witterServiceV2\ConsoleApplication3\Worker\Worker.cs:line 17
at ConsoleApplication3.TwitterService..ctor() in C:\Projets\Smoney\server\App
lisExternes\TwitterServiceV2\ConsoleApplication3\TwitterService.cs:line 67
at ConsoleApplication3.Program.<Main>b__2(HostSettings name) in C:\Projets\Sm
oney\server\ApplisExternes\TwitterServiceV2\ConsoleApplication3\Program.cs:line
17
at Topshelf.Builders.DelegateServiceBuilder1.Build(HostSettings settings)
--- End of inner exception stack trace ---
at Topshelf.Builders.DelegateServiceBuilder
1.Build(HostSettings settings)
at Topshelf.Builders.RunBuilder.Build(ServiceBuilder serviceBuilder)
at Topshelf.HostConfigurators.HostConfiguratorImpl.CreateHost()
at Topshelf.HostFactory.New(Action`1 configureCallback)
Topshelf.HostFactory Error: 0 : The service terminated abnormally, Topshelf.Serv
iceBuilderException: An exception occurred creating the service: TwitterService
---> System.TypeInitializationException: The type initializer for 'Tweetinvi.Str
eam' threw an exception. ---> System.TypeInitializationException: The type initi
alizer for 'Tweetinvi.TweetinviContainer' threw an exception. ---> System.TypeLo
adException: Method 'AddWebException' in type 'Tweetinvi.Logic.Exceptions.Except
ionHandler' from assembly 'Tweetinvi.Logic, Version=0.9.7.1, Culture=neutral, Pu
blicKeyToken=7247f14397bf67b9' does not have an implementation.
at Tweetinvi.Logic.TweetinviLogicModule.InitializeExceptionHandler()
at Tweetinvi.Logic.TweetinviLogicModule.Initialize()
at Tweetinvi.Injectinvi.AutofacContainer.InitializeModules()
at Tweetinvi.Injectinvi.AutofacContainer.Initialize()
at Tweetinvi.Injectinvi.AutofacContainer..ctor()
at Tweetinvi.TweetinviContainer..cctor()

What surprised me is this part :

__Method 'AddWebException' in type 'Tweetinvi.Logic.Exceptions.
ExceptionHandler' from assembly 'Tweetinvi.Logic, Version=0.9.7.1, Culture=neutr
al, PublicKeyToken=7247f14397bf67b9' does not have an implementation.__

Can you please tell me what could be the problem?

Thanks in advance
Coordinator
Jun 3, 2015 at 5:15 PM
Hi Adimo,

Thank you very much for contacting me here with your issue. As your other post suggests the issue has not been fixed. I must have forget about it.

Would you mind giving me very precise details on how you deploy your application?
I know Tweetinvi works in Web Deployed application so there must be an issue with the environment.

You can contact me privately if you do not want to share such information publicly.
Also would you be open to give me access to the server you are deploying to? Through credentials/remote desktop/skype meeting?

Cheers,
Linvi
Jun 3, 2015 at 5:24 PM
Hello Linvi,
Thanks for your reply
Even I don't have access to the deployment server since It's really critical the server doesn't break(this case was an exception i could test since the problem is persistent)
As for the service, It's just a Windows Service , using TopShelf , which allows to execute it as a console app(for fast test and debug)
The Service runs on My Machine as well as pre-Production Service
Searching the web I didn't have a conclusive answer
Could it be a DLL conflict issue , may be I'm not sure how this could occure ?

Regards,
Coordinator
Jun 3, 2015 at 5:51 PM
Ok,

It is usually way faster to find environment issues on the affected machine.

Would you please give me the following information:
  • OS and version (e.g. Windows Server 2008)
  • Service Pack
  • .NET Framework installed
  • .NET Framework target of the project
  • Have you tried making the service work without TopShelf?
  • Have you encountered any issue on another environment of production? On another pre-production environment?
  • I will issue you new DLLs as well as debug DLLs to see if this has any effect on the bug.
Cheers,
Linvi
Jun 3, 2015 at 7:36 PM
Hello Linvi,
Thanks for your response

OS and version (e.g. Windows Server 2008)==> Windows server 2008 sp2
.NET Framework installed 4.0
.NET Framework target of the project 4.0
Have you tried making the service work without TopShelf? yes using classic windows services
Have you encountered any issue on another environment of production? On another pre-production environment? no only one pre-production environment and several local machines with no problems
I will issue you new DLLs as well as debug DLLs to see if this has any effect on the bug.

Thanks for your help

Regards,
Coordinator
Jun 4, 2015 at 1:16 AM
Hello,

I have had a quick look on the internet. First of all, could you please verify that you remove all the libraries of your project/gac manually (delete .dll files).
Then please rebuild your project and try again.

If this still fails please use a new set of .dll that I have created for you. Please note that these assemblies have been compiled in debug mode for the sake of this bug.

Tweetinvi 0.9.8.0 - Pre-Release - Debug.zip

Please get back to me if this results in a success :) or in nothing :'(

Cheers,
Linvi
Jun 10, 2015 at 11:15 AM
Edited Jun 10, 2015 at 11:19 AM
Hello Linvi,
I have just tested the solution with the new dlls you gave me and the problem is not resolved with the same error message shown earlier with a minor difference

Topshelf.HostFactory Error: 0 : An exception occurred creating the host, Topshel
f.ServiceBuilderException: An exception occurred creating the service: TwitterSe
rvice ---> System.TypeInitializationException: The type initializer for 'Tweetin
vi.TwitterCredentials' threw an exception. ---> System.TypeInitializationExcepti
on: The type initializer for 'Tweetinvi.TweetinviContainer' threw an exception.
---> System.TypeLoadException: Method 'AddWebException' in type 'Tweetinvi.Logic
.Exceptions.ExceptionHandler' from assembly 'Tweetinvi.Logic, Version=0.9.8.0, C
ulture=neutral, PublicKeyToken=7247f14397bf67b9' does not have an implementation
.
at Tweetinvi.Logic.TweetinviLogicModule.InitializeExceptionHandler()
at Tweetinvi.Logic.TweetinviLogicModule.Initialize()
at Tweetinvi.Injectinvi.AutofacContainer.InitializeModules()
at Tweetinvi.Injectinvi.AutofacContainer.Initialize()
at Tweetinvi.Injectinvi.AutofacContainer..ctor()
at Tweetinvi.TweetinviContainer..cctor()
--- End of inner exception stack trace ---
at Tweetinvi.TweetinviContainer.ResolveT
at Tweetinvi.TwitterCredentials..cctor()
--- End of inner exception stack trace ---
at Tweetinvi.TwitterCredentials.SetCredentials(String userAccessToken, String
userAccessSecret, String consumerKey, String consumerSecret)
at TwitterService.SmoneyProxy.SetCredentials() in C:\serveur\server\ApplisExt
ernes\TwitterServiceV2\ConsoleApplication3\Proxy\SmoneyProxy.cs:line 67
at TwitterService.TwitterPayment..ctor() in C:\serveur\server\ApplisExternes\
TwitterServiceV2\ConsoleApplication3\TwitterPayment.cs:line 32
at TwitterService.Worker..ctor() in C:\serveur\server\ApplisExternes\TwitterS
erviceV2\ConsoleApplication3\Worker\Worker.cs:line 17
at ConsoleApplication3.TwitterService..ctor() in C:\serveur\server\ApplisExte
rnes\TwitterServiceV2\ConsoleApplication3\TwitterService.cs:line 66
at ConsoleApplication3.Program.<Main>b__2(HostSettings name) in C:\serveur\se
rver\ApplisExternes\TwitterServiceV2\ConsoleApplication3\Program.cs:line 17
at Topshelf.Builders.DelegateServiceBuilder1.Build(HostSettings settings)
--- End of inner exception stack trace ---
at Topshelf.Builders.DelegateServiceBuilder
1.Build(HostSettings settings)
at Topshelf.Builders.RunBuilder.Build(ServiceBuilder serviceBuilder)
at Topshelf.HostConfigurators.HostConfiguratorImpl.CreateHost()
at Topshelf.HostFactory.New(Action1 configureCallback)
Topshelf.HostFactory Error: 0 : The service terminated abnormally, Topshelf.Serv
iceBuilderException: An exception occurred creating the service: TwitterService
---> System.TypeInitializationException: The type initializer for 'Tweetinvi.Twi
tterCredentials' threw an exception. ---> System.TypeInitializationException: Th
e type initializer for 'Tweetinvi.TweetinviContainer' threw an exception. ---> S
ystem.TypeLoadException: Method 'AddWebException' in type 'Tweetinvi.Logic.Excep
tions.ExceptionHandler' from assembly 'Tweetinvi.Logic, Version=0.9.8.0, Culture
=neutral, PublicKeyToken=7247f14397bf67b9' does not have an implementation.
at Tweetinvi.Logic.TweetinviLogicModule.InitializeExceptionHandler()
at Tweetinvi.Logic.TweetinviLogicModule.Initialize()
at Tweetinvi.Injectinvi.AutofacContainer.InitializeModules()
at Tweetinvi.Injectinvi.AutofacContainer.Initialize()
at Tweetinvi.Injectinvi.AutofacContainer..ctor()
at Tweetinvi.TweetinviContainer..cctor()
--- End of inner exception stack trace ---
at Tweetinvi.TweetinviContainer.Resolve[T]()
at Tweetinvi.TwitterCredentials..cctor()
--- End of inner exception stack trace ---
at Tweetinvi.TwitterCredentials.SetCredentials(String userAccessToken, String
userAccessSecret, String consumerKey, String consumerSecret)
at TwitterService.SmoneyProxy.SetCredentials() in C:\serveur\server\ApplisExt
ernes\TwitterServiceV2\ConsoleApplication3\Proxy\SmoneyProxy.cs:line 67
at TwitterService.TwitterPayment..ctor() in C:\serveur\server\ApplisExternes\
TwitterServiceV2\ConsoleApplication3\TwitterPayment.cs:line 32
at TwitterService.Worker..ctor() in C:\serveur\server\ApplisExternes\TwitterS
erviceV2\ConsoleApplication3\Worker\Worker.cs:line 17
at ConsoleApplication3.TwitterService..ctor() in C:\serveur\server\ApplisExte
rnes\TwitterServiceV2\ConsoleApplication3\TwitterService.cs:line 66
at ConsoleApplication3.Program.<Main>b__2(HostSettings name) in C:\serveur\se
rver\ApplisExternes\TwitterServiceV2\ConsoleApplication3\Program.cs:line 17
at Topshelf.Builders.DelegateServiceBuilder
1.Build(HostSettings settings)
--- End of inner exception stack trace ---
at Topshelf.Builders.DelegateServiceBuilder1.Build(HostSettings settings)
at Topshelf.Builders.RunBuilder.Build(ServiceBuilder serviceBuilder)
at Topshelf.HostConfigurators.HostConfiguratorImpl.CreateHost()
at Topshelf.HostFactory.New(Action
1 configureCallback)
at Topshelf.HostFactory.Run(Action`1 configureCallback)


Thanks for your help
Coordinator
Jun 29, 2015 at 1:10 AM
Hi,

Would you please try using the new nuget package.

**Install-Package TweetinviAPI -Version 0.9.8.1-forNET40 -Pre **

Cheers,
Linvi