-
Notifications
You must be signed in to change notification settings - Fork 218
Xamarin Android, iOS and Mono
The Tweetinvi DLLs being Portable Class Libraries should be 100% compatible with Xamarin Android, iOS and Mono projects targeting a version of Mono compatible with .NET 4.0. I am personally performing minor testing on the Xamarin Android and the Mono platforms but please send as much feedback as you can!
When executing an application using Tweetinvi with Mono you can encounter the following issues :
Unhandled Exception:
System.TypeInitializationException: The type initializer for 'Tweetinvi.Auth' threw an exception. ---> System.ArgumentEx
ception: The type 'Tweetinvi.Streams.StreamTask' is not assignable to service 'Tweetinvi.Streams.IStreamTask'.
at Autofac.Builder.RegistrationBuilder.CreateRegistration (Guid id, Autofac.Builder.RegistrationData data, IInstanceAc
tivator activator, IEnumerable`1 services, IComponentRegistration target) <0x3c431c8 + 0x00153> in <filename unknown>:0
at Autofac.Builder.RegistrationBuilder.CreateRegistration[TLimit,TActivatorData,TSingleRegistrationStyle] (IRegistrati
onBuilder`3 builder) <0x3c42f18 + 0x00107> in <filename unknown>:0
at Autofac.Builder.RegistrationBuilder.RegisterSingleComponent[TLimit,TActivatorData,TSingleRegistrationStyle] (ICompo
nentRegistry cr, IRegistrationBuilder`3 builder) <0x3c42d68 + 0x00037> in <filename unknown>:0
at Autofac.RegistrationExtensions+<>c__DisplayClassa`1[TImplementer].<RegisterType>b__9 (IComponentRegistry cr) <0x3c4
48c0 + 0x0002f> in <filename unknown>:0
at Autofac.ContainerBuilder.Build (IComponentRegistry componentRegistry, Boolean excludeDefaultModules) <0x3c42010 + 0
x00081> in <filename unknown>:0
at Autofac.ContainerBuilder.Build (ContainerBuildOptions options) <0x3c3e8c0 + 0x0005b> in <filename unknown>:0
at Tweetinvi.Injectinvi.AutofacContainer.Initialize () <0x3c35c48 + 0x0014b> in <filename unknown>:0
at Tweetinvi.TweetinviContainer.Resolve[T] () <0x3c35b70 + 0x0003a> in <filename unknown>:0
at Tweetinvi.Auth.Initialize () <0x3c35b10 + 0x0000f> in <filename unknown>:0
at Tweetinvi.Auth..cctor () <0x3c35af0 + 0x0000b> in <filename unknown>:0
--- End of inner exception stack trace ---
at Examplinvi.Program.Main () <0x3bc1120 + 0x0019b> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'Tweetinvi.Auth' threw a
n exception. ---> System.ArgumentException: The type 'Tweetinvi.Streams.StreamTask' is not assignable to service 'Tweeti
nvi.Streams.IStreamTask'.
at Autofac.Builder.RegistrationBuilder.CreateRegistration (Guid id, Autofac.Builder.RegistrationData data, IInstanceAc
tivator activator, IEnumerable`1 services, IComponentRegistration target) <0x3c431c8 + 0x00153> in <filename unknown>:0
at Autofac.Builder.RegistrationBuilder.CreateRegistration[TLimit,TActivatorData,TSingleRegistrationStyle] (IRegistrati
onBuilder`3 builder) <0x3c42f18 + 0x00107> in <filename unknown>:0
at Autofac.Builder.RegistrationBuilder.RegisterSingleComponent[TLimit,TActivatorData,TSingleRegistrationStyle] (ICompo
nentRegistry cr, IRegistrationBuilder`3 builder) <0x3c42d68 + 0x00037> in <filename unknown>:0
at Autofac.RegistrationExtensions+<>c__DisplayClassa`1[TImplementer].<RegisterType>b__9 (IComponentRegistry cr) <0x3c4
48c0 + 0x0002f> in <filename unknown>:0
at Autofac.ContainerBuilder.Build (IComponentRegistry componentRegistry, Boolean excludeDefaultModules) <0x3c42010 + 0
x00081> in <filename unknown>:0
at Autofac.ContainerBuilder.Build (ContainerBuildOptions options) <0x3c3e8c0 + 0x0005b> in <filename unknown>:0
at Tweetinvi.Injectinvi.AutofacContainer.Initialize () <0x3c35c48 + 0x0014b> in <filename unknown>:0
at Tweetinvi.TweetinviContainer.Resolve[T] () <0x3c35b70 + 0x0003a> in <filename unknown>:0
at Tweetinvi.Auth.Initialize () <0x3c35b10 + 0x0000f> in <filename unknown>:0
at Tweetinvi.Auth..cctor () <0x3c35af0 + 0x0000b> in <filename unknown>:0
--- End of inner exception stack trace ---
at Examplinvi.Program.Main () <0x3bc1120 + 0x0019b> in <filename unknown>:0
This issue can be fixed by copying the library System.Net.Http
from the nuget packages into your bin folder. The DLL is located in the nuget packages under the folder Microsoft.Net.Http.x.x.xxx
.
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
at Tweetinvi.Factories.User.UserFactory.GetLoggedUser (ITwitterCredentials credentials, IGetLoggedUserParameters parameters) <0x3c271d8 + 0x00151>
in <filename unknown>:0
at Tweetinvi.User.GetLoggedUser (ITwitterCredentials credentials, IGetLoggedUserParameters parameters) <0x3c26570 + 0x00026> in <filename unknown>
:0
at Examplinvi.Program.Main () <0x3b91118 + 0x000eb> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
at Tweetinvi.Factories.User.UserFactory.GetLoggedUser (ITwitterCredentials credentials, IGetLoggedUserParameters parameters) <0x3c271d8 + 0x00151>
in <filename unknown>:0
at Tweetinvi.User.GetLoggedUser (ITwitterCredentials credentials, IGetLoggedUserParameters parameters) <0x3c26570 + 0x00026> in <filename unknown>
:0
at Examplinvi.Program.Main () <0x3b91118 + 0x000eb> in <filename unknown>:0
If you encounter this issue or that ALL of the objects returned by Tweetinvi are null, it mean that there is yet another issue with System.Net.Http
.
To solve it you must add the following line of code in your main application. This line cannot be added in Tweetinvi as the ServicePointManager
is not available in the PCL.
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { return true; };
Source : https://forums.xamarin.com/discussion/comment/159003/#Comment_159003