-
Notifications
You must be signed in to change notification settings - Fork 446
SignalR client not working in iOS #2933
Comments
Our sample worked on an iOS device last time I checked, but something might have broken here. Can you try the sample app and see if it also shows the same issue? Maybe something is a little different about your application and that's causing the problem. Would you be able to post an application that reproduces the error? That would make it a lot easier to track this down. |
Many thanks for responding. Let me try your sample app first, I'll check back as soon as I've had a chance to test it on an actual iOS device. |
I was able to build and run your iOS sample, it works flawlessly on my iPhone. Next step for me is to identify the difference(s) between your sample and my app. The relevant code bits look identical, so I'm wondering if there is a clash somewhere between other dependencies. At least now I know it can work... Once I find the issue on my side I'll post it here, maybe others have run into the same problem. Thanks for your help! |
If you're able to post a complete sample of an app that fails in this way somewhere, I'm happy to try to take a look and help out. Hope that helps find your issue! I think you're probably right that the issue lies in dependencies :). If you're comfortable posting your dependencies, you could also just post your |
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): I 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:
I 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:
That 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. However, now when I run the sample app, I get the exact same exception that I get in my own app:
As 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. It 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. |
I expect the problem is that the linker has removed code from HttpConnectionFactory that we need in order to activate it with DI. /cc @davidfowl |
Yes, it certainly does look that way - I was able to refactor my code to remove the dependency on System.Drawing.dll, which allowed me to revert back to Link Framework SDKs Only. Everything builds and SignalR now works as expected on the iPhone. Happiness. |
Glad you found a solution to your problem! |
Based on the info here aspnet/Announcements#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:
The code above works in the iPhone simulator, but crashes on the device itself.
I 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).
Any help is highly appreciated.
The text was updated successfully, but these errors were encountered: