linvi / tweetinvi

Tweetinvi, an intuitive Twitter C# library for the REST and Stream API. It supports .NET, .NETCore, UAP (Xamarin)...
MIT License
1k stars 220 forks source link

Mono missing winhttp.dll #456

Closed mackcoding closed 7 years ago

mackcoding commented 7 years ago

I'm using the latest mono version for Debian 8, and I just deployed Tweetinvi to the machine (ASP.NET app) but I am getting this error:

image

 Application Exception

 System.DllNotFoundException
 winhttp.dll

 Description: HTTP 500.Error processing request.
 Details: Non-web exception. Exception origin (name of application or object): Microsoft.Threading.Tasks.
 Exception stack trace:
   at (wrapper managed-to-native) Interop+WinHttp:WinHttpOpen (intptr,uint,string,string,int)
   at System.Net.Http.WinHttpHandler.EnsureSessionHandleExists (System.Net.Http.WinHttpRequestState state) [0x00089] in <c0e04d9c70cf48a6a179fbfd8ce69fd0>:0 
   at System.Net.Http.WinHttpHandler+<StartRequest>d__103.MoveNext () [0x00095] in <c0e04d9c70cf48a6a179fbfd8ce69fd0>:0 
 --- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00042] in <1c7d529d87ec4bdcbde02e9494f3b5ae>:0 
   at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess (System.Threading.Tasks.Task task) [0x0001c] in <1c7d529d87ec4bdcbde02e9494f3b5ae>:0 
   at Microsoft.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00009] in <1c7d529d87ec4bdcbde02e9494f3b5ae>:0 
   at Microsoft.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <1c7d529d87ec4bdcbde02e9494f3b5ae>:0 
   at Tweetinvi.WebLogic.HttpClientWebHelper+<GetHttpResponse>d__0.MoveNext () [0x00104] in <89729572ccf046a586dfe214f5c4b961>:0 
 Version Information: 4.6.2 (Stable 4.6.2.16/ac9e222 Tue Jan 3 11:48:26 UTC 2017); ASP.NET Version: 4.0.30319.42000
 Powered by Mono

Mono JIT compiler version 4.6.2 (Stable 4.6.2.16/ac9e222 Tue Jan 3 11:48:26 UTC 2017) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com TLS: __thread SIGSEGV: altstack Notifications: epoll Architecture: amd64 Disabled: none Misc: softdebug LLVM: supported, not enabled. GC: sgen

Running on Debian 8.7 .NET Framework 4.6.

Any clues? It appears to be linked to system.net. Thanks!

mackcoding commented 7 years ago

Ok so, I wiped everything and redeployed. I get this now.

Application Exception
System.TypeLoadException
Failure has occurred while loading a type.

Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): Tweetinvi.
Exception stack trace:
  at Tweetinvi.WebLogic.WebRequestExecutor+<>c__DisplayClass4_0.<ExecuteQuery>b__0 () [0x00002] in <89729572ccf046a586dfe214f5c4b961>:0 
Version Information: 4.6.2 (Stable 4.6.2.16/ac9e222 Tue Jan 3 11:48:26 UTC 2017); ASP.NET Version: 4.0.30319.42000
Powered by Mono
linvi commented 7 years ago

Hello there, I will try to take a look during this week.

Sorry for the delay, I have too much on my plate right now.

mackcoding commented 7 years ago

Thanks, I'll do some testing as well. I tried different versions of tweetinvi, no change. I ran this on another dev machine and seeing the same error:

Application Exception
System.TypeLoadException
 Failure has occurred while loading a type.

 Description: HTTP 500.Error processing request.
 Details: Non-web exception. Exception origin (name of application or object): Tweetinvi.
 Exception stack trace:
   at Tweetinvi.WebLogic.WebRequestExecutor+<>c__DisplayClass4_0.<ExecuteQuery>b__0 () [0x00002] in <2d049c9b1a354d9e82999d58c3c2efca>:0 
 Version Information: 4.6.2 (Stable 4.6.2.7/08fd525 Mon Nov 14 12:30:00 UTC 2016); ASP.NET Version: 4.0.30319.42000
 Powered by Mono

Here's another

 System.BadImageFormatException
 Could not resolve field token 0x04000f49

 Description: HTTP 500.Error processing request.
 Details: Non-web exception. Exception origin (name of application or object): Tweetinvi.
 Exception stack trace:
   at Tweetinvi.WebLogic.WebRequestExecutor+<>c__DisplayClass4_0.<ExecuteQuery>b__0 () [0x00002] in <2d049c9b1a354d9e82999d58c3c2efca>:0 
 Version Information: 4.6.2 (Stable 4.6.2.7/08fd525 Mon Nov 14 12:30:00 UTC 2016); ASP.NET Version: 4.0.30319.42000

I downgraded my project to 4.5 from 4.61:

 System.ArgumentException
 The type 'Tweetinvi.WebLogic.TwitterQuery' is not assignable to service 'Tweetinvi.Models.ITwitterQuery'.

 Description: HTTP 500.Error processing request.
 Details: Non-web exception. Exception origin (name of application or object): Autofac.
 Exception stack trace:
   at Autofac.Builder.RegistrationBuilder.CreateRegistration (System.Guid id, Autofac.Builder.RegistrationData data, Autofac.Core.IInstanceActivator activator, System.Collections.Generic.IEnumerable`1[T] services, Autofac.Core.IComponentRegistration target) [0x0007f] in <d2e21a4947d7428dab6692e67eb66c09>:0 
   at Autofac.Builder.RegistrationBuilder.CreateRegistration[TLimit,TActivatorData,TSingleRegistrationStyle] (Autofac.Builder.IRegistrationBuilder`3[TLimit,TActivatorData,TRegistrationStyle] builder) [0x00053] in <d2e21a4947d7428dab6692e67eb66c09>:0 
   at Autofac.Builder.RegistrationBuilder.RegisterSingleComponent[TLimit,TActivatorData,TSingleRegistrationStyle] (Autofac.Core.IComponentRegistry cr, Autofac.Builder.IRegistrationBuilder`3[TLimit,TActivatorData,TRegistrationStyle] builder) [0x0000e] in <d2e21a4947d7428dab6692e67eb66c09>:0 
   at Autofac.RegistrationExtensions+<>c__DisplayClass3_0`1[TImplementer].<RegisterType>b__0 (Autofac.Core.IComponentRegistry cr) [0x00000] in <d2e21a4947d7428dab6692e67eb66c09>:0 
   at Autofac.ContainerBuilder.Build (Autofac.Core.IComponentRegistry componentRegistry, System.Boolean excludeDefaultModules) [0x00046] in <d2e21a4947d7428dab6692e67eb66c09>:0 
   at Autofac.ContainerBuilder.Build (Autofac.Builder.ContainerBuildOptions options) [0x00013] in <d2e21a4947d7428dab6692e67eb66c09>:0 
   at Tweetinvi.Injectinvi.AutofacContainer.Initialize () [0x0003b] in <89729572ccf046a586dfe214f5c4b961>:0 
   at Tweetinvi.TweetinviContainer.Resolve[T] () [0x0000f] in <89729572ccf046a586dfe214f5c4b961>:0 
   at Tweetinvi.Auth.Initialize () [0x00000] in <89729572ccf046a586dfe214f5c4b961>:0 
   at Tweetinvi.Auth..cctor () [0x00000] in <89729572ccf046a586dfe214f5c4b961>:0 
 Version Information: 4.6.2 (Stable 4.6.2.16/ac9e222 Tue Jan 3 11:48:26 UTC 2017); ASP.NET Version: 4.0.30319.42000

Now changed to 4.6:

 Application Exception
 System.DllNotFoundException
 winhttp.dll

 Description: HTTP 500.Error processing request.
 Details: Non-web exception. Exception origin (name of application or object): Microsoft.Threading.Tasks.
 Exception stack trace:
   at (wrapper managed-to-native) Interop+WinHttp:WinHttpOpen (intptr,uint,string,string,int)
   at System.Net.Http.WinHttpHandler.EnsureSessionHandleExists (System.Net.Http.WinHttpRequestState state) [0x00089] in <c0e04d9c70cf48a6a179fbfd8ce69fd0>:0 
   at System.Net.Http.WinHttpHandler+<StartRequest>d__103.MoveNext () [0x00095] in <c0e04d9c70cf48a6a179fbfd8ce69fd0>:0 
 --- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00042] in <1c7d529d87ec4bdcbde02e9494f3b5ae>:0 
   at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess (System.Threading.Tasks.Task task) [0x0001c] in <1c7d529d87ec4bdcbde02e9494f3b5ae>:0 
   at Microsoft.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00009] in <1c7d529d87ec4bdcbde02e9494f3b5ae>:0 
   at Microsoft.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <1c7d529d87ec4bdcbde02e9494f3b5ae>:0 
   at Tweetinvi.WebLogic.HttpClientWebHelper+<GetHttpResponse>d__0.MoveNext () [0x00104] in <89729572ccf046a586dfe214f5c4b961>:0 
 Version Information: 4.6.2 (Stable 4.6.2.16/ac9e222 Tue Jan 3 11:48:26 UTC 2017); ASP.NET Version: 4.0.30319.42000
 Powered by Mono

Downgraded tweetinvi to 1.1.1 from latest in nuget:

 System.TypeInitializationException
 The type initializer for 'Tweetinvi.TweetinviContainer' threw an exception.

 Description: HTTP 500.Error processing request.
 Details: Non-web exception. Exception origin (name of application or object): Tweetinvi.
 Exception stack trace:
   at Tweetinvi.Auth.Initialize () [0x00000] in <38640a8c673547a8aad547603ef20773>:0 
   at Tweetinvi.Auth..cctor () [0x00000] in <38640a8c673547a8aad547603ef20773>:0 
 Version Information: 4.6.2 (Stable 4.6.2.16/ac9e222 Tue Jan 3 11:48:26 UTC 2017); ASP.NET Version: 4.0.30319.42000

Same result with tweetinvi 1.0. I'll mess with it again tomorrow most likely. Going to write a basic app to see what happens.

mackcoding commented 7 years ago

OK, I'll go to bed after this I promise! I created a very, very, basic .NET APP 4.61:

using System;
using Tweetinvi;

namespace test_twitter
{
    class Program
    {
        static void Main(string[] args)
        {
            Auth.SetUserCredentials("secret", "secret", 
                "secret", "secret");
            var tweets = Timeline.GetHomeTimeline();

            foreach (var item in tweets)
            {
                Console.WriteLine("text:" + item.Text);
            }

            Console.ReadLine();
        }
    }
}

Works on windows, but on Linux:

root@devmachine1:/var/www/twitter# mono test-twitter.exe

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'Tweetinvi.Auth' threw an exception. ---> System.ArgumentException: The type 'Tweetinvi.WebLogic.TwitterQuery' is not assignable to service 'Tweetinvi.Models.ITwitterQuery'.
  at Autofac.Builder.RegistrationBuilder.CreateRegistration (System.Guid id, Autofac.Builder.RegistrationData data, Autofac.Core.IInstanceActivator activator, System.Collections.Generic.IEnumerable`1[T] services, Autofac.Core.IComponentRegistration target) [0x00078] in <ca1ca41f44e0487e9a15b2f64e38c7de>:0
  at Autofac.Builder.RegistrationBuilder.CreateRegistration[TLimit,TActivatorData,TSingleRegistrationStyle] (Autofac.Builder.IRegistrationBuilder`3[TLimit,TActivatorData,TRegistrationStyle] builder) [0x0005b] in <ca1ca41f44e0487e9a15b2f64e38c7de>:0
  at Autofac.Builder.RegistrationBuilder.RegisterSingleComponent[TLimit,TActivatorData,TSingleRegistrationStyle] (Autofac.Core.IComponentRegistry cr, Autofac.Builder.IRegistrationBuilder`3[TLimit,TActivatorData,TRegistrationStyle] builder) [0x0000e] in <ca1ca41f44e0487e9a15b2f64e38c7de>:0
  at Autofac.RegistrationExtensions+<>c__DisplayClassa`1[TImplementer].<RegisterType>b__9 (Autofac.Core.IComponentRegistry cr) [0x00000] in <ca1ca41f44e0487e9a15b2f64e38c7de>:0
  at Autofac.ContainerBuilder.Build (Autofac.Core.IComponentRegistry componentRegistry, System.Boolean excludeDefaultModules) [0x00047] in <ca1ca41f44e0487e9a15b2f64e38c7de>:0
  at Autofac.ContainerBuilder.Build (Autofac.Builder.ContainerBuildOptions options) [0x0000d] in <ca1ca41f44e0487e9a15b2f64e38c7de>:0
  at Tweetinvi.Injectinvi.AutofacContainer.Initialize () [0x0003b] in <89729572ccf046a586dfe214f5c4b961>:0
  at Tweetinvi.TweetinviContainer.Resolve[T] () [0x0000f] in <89729572ccf046a586dfe214f5c4b961>:0
  at Tweetinvi.Auth.Initialize () [0x00000] in <89729572ccf046a586dfe214f5c4b961>:0
  at Tweetinvi.Auth..cctor () [0x00000] in <89729572ccf046a586dfe214f5c4b961>:0
   --- End of inner exception stack trace ---
  at test_twitter.Program.Main (System.String[] args) [0x00001] in <40ca3496c241406e9b0de74e8069cdb9>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'Tweetinvi.Auth' threw an exception. ---> System.ArgumentException: The type 'Tweetinvi.WebLogic.TwitterQuery' is not assignable to service 'Tweetinvi.Models.ITwitterQuery'.
  at Autofac.Builder.RegistrationBuilder.CreateRegistration (System.Guid id, Autofac.Builder.RegistrationData data, Autofac.Core.IInstanceActivator activator, System.Collections.Generic.IEnumerable`1[T] services, Autofac.Core.IComponentRegistration target) [0x00078] in <ca1ca41f44e0487e9a15b2f64e38c7de>:0
  at Autofac.Builder.RegistrationBuilder.CreateRegistration[TLimit,TActivatorData,TSingleRegistrationStyle] (Autofac.Builder.IRegistrationBuilder`3[TLimit,TActivatorData,TRegistrationStyle] builder) [0x0005b] in <ca1ca41f44e0487e9a15b2f64e38c7de>:0
  at Autofac.Builder.RegistrationBuilder.RegisterSingleComponent[TLimit,TActivatorData,TSingleRegistrationStyle] (Autofac.Core.IComponentRegistry cr, Autofac.Builder.IRegistrationBuilder`3[TLimit,TActivatorData,TRegistrationStyle] builder) [0x0000e] in <ca1ca41f44e0487e9a15b2f64e38c7de>:0
  at Autofac.RegistrationExtensions+<>c__DisplayClassa`1[TImplementer].<RegisterType>b__9 (Autofac.Core.IComponentRegistry cr) [0x00000] in <ca1ca41f44e0487e9a15b2f64e38c7de>:0
  at Autofac.ContainerBuilder.Build (Autofac.Core.IComponentRegistry componentRegistry, System.Boolean excludeDefaultModules) [0x00047] in <ca1ca41f44e0487e9a15b2f64e38c7de>:0
  at Autofac.ContainerBuilder.Build (Autofac.Builder.ContainerBuildOptions options) [0x0000d] in <ca1ca41f44e0487e9a15b2f64e38c7de>:0
  at Tweetinvi.Injectinvi.AutofacContainer.Initialize () [0x0003b] in <89729572ccf046a586dfe214f5c4b961>:0
  at Tweetinvi.TweetinviContainer.Resolve[T] () [0x0000f] in <89729572ccf046a586dfe214f5c4b961>:0
  at Tweetinvi.Auth.Initialize () [0x00000] in <89729572ccf046a586dfe214f5c4b961>:0
  at Tweetinvi.Auth..cctor () [0x00000] in <89729572ccf046a586dfe214f5c4b961>:0
   --- End of inner exception stack trace ---
  at test_twitter.Program.Main (System.String[] args) [0x00001] in <40ca3496c241406e9b0de74e8069cdb9>:0
root@devmachine1:/var/www/twitter#
mackcoding commented 7 years ago

Alright, so I re-read https://github.com/linvi/tweetinvi/wiki/Xamarin-Android,-iOS-and-Mono. In the packages folder, I copied (all) dlls from 'src\packages\Microsoft.Net.Http.2.2.29\lib' to my BIN folder. It works. YAY!

Not sure if you want to close this, or implement some kind of fix. I'll leave it to you 👍

linvi commented 7 years ago

Great. In addition to this please note that version 2.0 is now based on .NETStandard which should avoid this type of problem.