{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/SignalR/issues/2933","repository_url":"https://api.github.com/repos/aspnet/SignalR","labels_url":"https://api.github.com/repos/aspnet/SignalR/issues/2933/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/SignalR/issues/2933/comments","events_url":"https://api.github.com/repos/aspnet/SignalR/issues/2933/events","html_url":"https://github.com/aspnet/SignalR/issues/2933","id":358409785,"node_id":"MDU6SXNzdWUzNTg0MDk3ODU=","number":2933,"title":"SignalR client not working in iOS","user":{"login":"BillyMutt","id":41161630,"node_id":"MDQ6VXNlcjQxMTYxNjMw","avatar_url":"https://avatars1.githubusercontent.com/u/41161630?v=4","gravatar_id":"","url":"https://api.github.com/users/BillyMutt","html_url":"https://github.com/BillyMutt","followers_url":"https://api.github.com/users/BillyMutt/followers","following_url":"https://api.github.com/users/BillyMutt/following{/other_user}","gists_url":"https://api.github.com/users/BillyMutt/gists{/gist_id}","starred_url":"https://api.github.com/users/BillyMutt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BillyMutt/subscriptions","organizations_url":"https://api.github.com/users/BillyMutt/orgs","repos_url":"https://api.github.com/users/BillyMutt/repos","events_url":"https://api.github.com/users/BillyMutt/events{/privacy}","received_events_url":"https://api.github.com/users/BillyMutt/received_events","type":"User","site_admin":false},"labels":[{"id":945015764,"node_id":"MDU6TGFiZWw5NDUwMTU3NjQ=","url":"https://api.github.com/repos/aspnet/SignalR/labels/status:%20More%20Info","name":"status: More Info","color":"e580c2","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-09-09T20:35:22Z","updated_at":"2018-09-12T18:00:40Z","closed_at":null,"author_association":"NONE","body":"Based on the info here https://github.com/aspnet/Announcements/issues/305 I was hoping to finally get my Xamarin iOS client working with ASP.Net Core SignalR, but still no luck. I get an exception when the client tries to connect to the hub:\r\n\r\n```\r\n//  Connect to the SignalR hub.\r\nstring url = $\"http://{DataService.HostName}:{DataService.MainPort.ToString()}/hub\";\r\ntry\r\n{\r\n    MediaHubConnection = new HubConnectionBuilder().WithUrl(url).Build();\r\n}\r\ncatch (Exception e)\r\n{ // Handle exception }\r\n```\r\n\r\n> Exception: A suitable constructor for type Microsoft.AspNetCore.SignalR.Client.HttpConnectionFactory could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.\r\n\r\nThe code above works in the iPhone simulator, but crashes on the device itself. \r\n\r\nI am using Visual Studio 15.8.0 with Xamarin iOS 11.14.0.13 on Windows 10; Visual Studio for Mac 7.6.1 Build 9 with Xamarin iOS 11.14.0.13 on the Mac. Latest released Nugets for AspNetCore SignalR (server and client).\r\n\r\nAny help is highly appreciated."},"comment":{"url":"https://api.github.com/repos/aspnet/SignalR/issues/comments/420742291","html_url":"https://github.com/aspnet/SignalR/issues/2933#issuecomment-420742291","issue_url":"https://api.github.com/repos/aspnet/SignalR/issues/2933","id":420742291,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMDc0MjI5MQ==","user":{"login":"BillyMutt","id":41161630,"node_id":"MDQ6VXNlcjQxMTYxNjMw","avatar_url":"https://avatars1.githubusercontent.com/u/41161630?v=4","gravatar_id":"","url":"https://api.github.com/users/BillyMutt","html_url":"https://github.com/BillyMutt","followers_url":"https://api.github.com/users/BillyMutt/followers","following_url":"https://api.github.com/users/BillyMutt/following{/other_user}","gists_url":"https://api.github.com/users/BillyMutt/gists{/gist_id}","starred_url":"https://api.github.com/users/BillyMutt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BillyMutt/subscriptions","organizations_url":"https://api.github.com/users/BillyMutt/orgs","repos_url":"https://api.github.com/users/BillyMutt/repos","events_url":"https://api.github.com/users/BillyMutt/events{/privacy}","received_events_url":"https://api.github.com/users/BillyMutt/received_events","type":"User","site_admin":false},"created_at":"2018-09-12T18:00:40Z","updated_at":"2018-09-12T18:00:40Z","author_association":"NONE","body":"I was able to reproduce the problem by making a small change to your sample app (apologies for the long post, but I wanted to include all the relevant detail):\r\n\r\nI added a reference in the sample to one of my own assemblies (just some common, mostly legacy   classes I use throughout my app).  That assembly, in turn, references the following components:\r\n\r\n```\r\nusing System;\r\nusing System.Collections;\r\nusing System.Collections.Generic;\r\nusing System.Drawing;\r\nusing System.Collections.ObjectModel;\r\nusing System.ComponentModel.DataAnnotations;\r\nusing System.Drawing.Drawing2D;\r\nusing System.Drawing.Imaging;\r\nusing System.IO;\r\nusing System.Runtime.Serialization;\r\n```\r\nI modified the sample app very slightly to simply instantiate one of the classes in my assembly.  Building the sample app now produces the following error:\r\n\r\n> Error Could not AOT the assembly '/Users/user141861/Library/Caches/Xamarin/mtbs/builds/iOSClient/20dea21417163e8e9d56adc21b28d8f9/obj/iPhone/Release/mtouch-cache/3-Build/System.Drawing.dll'\tiOSClient\t\t\r\n\r\nThat jogged my memory: to get around this build error, I had to change the build options for my app, and now also for the sample app. Changing the linker behavior from _Link Framework SDKs Only_ to _Link All_  gets rid of the error and the sample app build succeeds. \r\n\r\n**However, now when I run the sample app, I get the exact same exception that I get in my own app:**\r\n\r\n> An error occurred while connecting: System.InvalidOperationException: A suitable constructor for type 'Microsoft.AspNetCore.SignalR.Client.HttpConnectionFactory' could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.\r\n> at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite (System.Type serviceType, System.Type implementationType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) <0x100dc68d0 + 0x00734> in <ef466db513bd4c67869506814ed622c5#98ca90be2f4ba6fc9197a6b1f218e40a>:0\r\n> at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact (Microsoft.Extensions.DependencyInjection.ServiceDescriptor descriptor, System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) <0x100dc6500 + 0x00117> in <ef466db513bd4c67869506814ed622c5#98ca90be2f4ba6fc9197a6b1f218e40a>:0\r\n> at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) <0x100dc6110 + 0x0005f> in <ef466db513bd4c67869506814ed622c5#98ca90be2f4ba6fc9197a6b1f218e40a>:0\r\n> at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain callSiteChain) <0x100dc5f70 + 0x000bb> in <ef466db513bd4c67869506814ed622c5#98ca90be2f4ba6fc9197a6b1f218e40a>:0\r\n> at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.CreateServiceAccessor (System.Type serviceType) <0x100dcc7a0 + 0x00053> in <ef466db513bd4c67869506814ed622c5#98ca90be2f4ba6fc9197a6b1f218e40a>:0\r\n> at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) <0x100362730 + 0x000b3> in <3c7b99a36820490fb2cbc5a6fc6b06d8#98ca90be2f4ba6fc9197a6b1f218e40a>:0\r\n> at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope serviceProviderEngineScope) <0x100dcc6f0 + 0x0003b> in <ef466db513bd4c67869506814ed622c5#98ca90be2f4ba6fc9197a6b1f218e40a>:0\r\n> at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService (System.Type serviceType) <0x100dcc680 + 0x0001f> in <ef466db513bd4c67869506814ed622c5#98ca90be2f4ba6fc9197a6b1f218e40a>:0\r\n> at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService (System.Type serviceType) <0x100dc5120 + 0x0003f> in <ef466db513bd4c67869506814ed622c5#98ca90be2f4ba6fc9197a6b1f218e40a>:0\r\n> at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T] (System.IServiceProvider provider) <0x100db78d0 + 0x0004b> in <4b47b422bc4c4615bbdebe1df9b21b0d#98ca90be2f4ba6fc9197a6b1f218e40a>:0\r\n> at Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilder.Build () <0x1009e90f0 + 0x0003f> in <1b2250b176e149ec8cda8e74d0229e3e#98ca90be2f4ba6fc9197a6b1f218e40a>:0\r\n> at iOSClient.ViewController+<ConnectDisconnectButton_TouchUpInside>d__32.MoveNext () <0x100198b90 + 0x002a3> in <79de77de19cf4e02af274cbf8100a615#98ca90be2f4ba6fc9197a6b1f218e40a>:0\r\n\r\nAs a final test, I reverted the sample app back to its original state by removing all traces of my assembly from the sample app, and built it again with the _Link All_ linker setting. Same problem, the exception is thrown when trying to connect to the SignalR hub.\r\n\r\nIt appears, therefore, that the linker behavior change is the culprit. I *may* be able to refactor my code to remove this requirement, but in the meantime it would be interesting to know if there might be a fix or a workaround for this behavior. Let me know if you need additional information, I'd be more than happy to help track this down.\r\n"}}
{"actor":{"display_login":"BillyMutt"}}