Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

.Net Core Server (docker container) -> Xamarin Client (Lollipop) #1833

Closed
Bidthedog opened this issue Apr 3, 2018 · 1 comment
Closed

.Net Core Server (docker container) -> Xamarin Client (Lollipop) #1833

Bidthedog opened this issue Apr 3, 2018 · 1 comment

Comments

@Bidthedog
Copy link

I've just been putting a proof of concept together for a .Net Core SignalR server that will be connected to from a number of other .Net Core apps, plus a number of Xamarin Form clients. I found a few other issues this is linked to - #1238 and #1518 in particular.

Project created under the following environment:

  • Visual Studio 2017 15.6.4
  • Win10 Enterprise 10.0.16299 Build 16299)
  • Xamarin 4.9.0.752

Steps to create were as follows:

  • .Net core WebAPI server app with additional SignalR hub registered, hosted in a Linux Docker container
  • A .Net Core console app (executed with dotnet run)
  • A Xamarin forms app using the .Net Standard code sharing strategy rather than Shared Project (targeting .Net Standard 2.0), targeting Android (running on Live Player on my Nexus 10 (Android 5.1, API 22), using the Master Detail template.

I have managed to get the WebAPI and console apps working fine - but I'm struggling with the Xamarin client.

I've been using the 1.0.0-preview1 packages. Tried the old Xamarin client nuget package but I found #985 that states they are incompatible, so I've given up on that.

.Net core server code is as follows:

    public class Startup {
        public Startup(IConfiguration configuration) {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        public void ConfigureServices(IServiceCollection services) {
            services.AddSignalR();
            services.AddMvc();
        }

        public void Configure(IApplicationBuilder app, IHostingEnvironment env) {
            if(env.IsDevelopment()) {
                app.UseDeveloperExceptionPage();
            }

            app.UseSignalR(r => { r.MapHub<CaseHub>("/case"); });
            app.UseMvc();
        }
    }

Case is a simple POCO (not particularly relevant):

    public class Case {
        public int CaseId { get; set; }

        public string Notes { get; set; }

        public string PatientId { get; set; }
    }

and the hub:

    public class CaseHub : Hub {
        public async Task Update(Case c) {
            Console.WriteLine($"SERVER RECEIVED UPDATE: CaseId: {c.CaseId}, Patient: {c.PatientId}, Notes: {c.Notes}");
            await Clients.All.SendAsync("caseUpdated", c);
        }
    }

.Net Core console app client code as follows (simple POC console app, definitely not production ready):

class Program {
        private static Random r = new Random();

        static void Main(string[] args) {
            MainAsync(args).GetAwaiter().GetResult();
        }

        static async Task MainAsync(string[] args) {
            Console.WriteLine("App Start");

            var caseHub = new HubConnection(new HttpConnection(new Uri("http://localhost:12340/case")), new JsonHubProtocol(), new NullLoggerFactory());
            caseHub.On<Case>("caseUpdated", c => Console.WriteLine($"CLIENT RECEIVED UPDATE: CaseId: {c.CaseId}, Patient: {c.PatientId}, Notes: {c.Notes}"));
            await caseHub.StartAsync();

            while(true) {
                // Send user update to hub
                var input = Console.ReadLine();
                await caseHub.SendAsync("update", new Case {
                    CaseId = r.Next(1,1000),
                    Notes = input,
                    PatientId = r.Next(1, 1000).ToString()
                });
            }
        }
    }

The server and client code works well - I get the relevant console output on all running instances of the client and server. Trying to get this to work in Xamarin, on the other hand, is proving problematic. I've attempted to use very similar client code to the above (altered to work with the Xamarin framework), but Xamarin refuses to play ball. Once I create the default Xamarin project (as outlined above), I take the following steps:

  • Test the app runs on my android device with Live Player (it does)
  • Add the Microsoft.AspNetCore.SignalR.Client (1.0.0-preview1-final) to the shared project (I've tried to add it to the Android project too, but it seems to totally screw up the dependency chain) via the Nuget Package Manager interface in VS (right click the project -> Manage Nuget Packages)
  • Accept License Agreement
  • Test app runs on Live Player again - get the following console output (this is new as I've gone through the process again - previously this seemed to work, but I would get errors when actually connecting to the hub via the Xamarin app - this looks to be the same as Doesn't connect with xamarin forms #1518):
Start Xamarin.Android, Samsung Nexus 10 Player, .This debug engine does not support exception conditions. The condition(s) will be ignored.

Attempting connection to debug address: 192.168.2.100:37847.
Connected to: 192.168.2.100:37847.
Deploying D:\git\test\Xamarin\Xamarin.Android\Xamarin.Android.csproj...
Got device info: Samsung Nexus 10 Player (Android) @ 192.168.2.100:37847
Synchronizing files...
Building and running...
Built with 1 messages.
(1,1): error: Failed to load assembly from stream: System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path "/data/data/com.xamarin.live/files/External/.nuget/packages/system.threading.tasks.extensions/4.5.0-preview1-26216-02/ref/netstandard2.0/System.Threading.Tasks.Extensions.dll".
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0017d] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
  at System.IO.File.OpenRead (System.String path) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at <StartupCode$Continuous-Core-Droid>[email protected] () [0x00012] in <5a7d391011b47c3aa745038310397d5a>:0 
  at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Threading.Tasks.Task.Execute () [0x00010] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.AggregateException: One or more errors occurred. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path "/data/data/com.xamarin.live/files/External/.nuget/packages/system.threading.tasks.extensions/4.5.0-preview1-26216-02/ref/netstandard2.0/System.Threading.Tasks.Extensions.dll".
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0017d] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
  at System.IO.File.OpenRead (System.String path) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at <StartupCode$Continuous-Core-Droid>[email protected] () [0x00012] in <5a7d391011b47c3aa745038310397d5a>:0 
  at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Threading.Tasks.Task.Execute () [0x00010] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.IO.DirectoryNotFoundException: Could not find a part of the path "/data/data/com.xamarin.live/files/External/.nuget/packages/system.threading.tasks.extensions/4.5.0-preview1-26216-02/ref/netstandard2.0/System.Threading.Tasks.Extensions.dll".
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0017d] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
  at System.IO.File.OpenRead (System.String path) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at <StartupCode$Continuous-Core-Droid>[email protected] () [0x00012] in <5a7d391011b47c3aa745038310397d5a>:0 
  at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Threading.Tasks.Task.Execute () [0x00010] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 <---
<---

Failed to debug your app.
  • Installed System.Threading.Tasks.Extensions via nuget (4.5.0-preview1-26216-02)
  • Test the app runs on Live Player again. Looks to be the same error:
Start Xamarin.Android, Samsung Nexus 10 Player, .
This debug engine does not support exception conditions. The condition(s) will be ignored.
Attempting connection to debug address: 192.168.2.100:37847.
Connected to: 192.168.2.100:37847.
Deploying D:\git\test\Xamarin\Xamarin.Android\Xamarin.Android.csproj...
Got device info: Samsung Nexus 10 Player (Android) @ 192.168.2.100:37847
Synchronizing files...
Building and running...
Built with 1 messages.
(1,1): error: Failed to load assembly from stream: System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path "/data/data/com.xamarin.live/files/External/.nuget/packages/system.threading.tasks.extensions/4.5.0-preview1-26216-02/ref/netstandard2.0/System.Threading.Tasks.Extensions.dll".
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0017d] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
  at System.IO.File.OpenRead (System.String path) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at <StartupCode$Continuous-Core-Droid>[email protected] () [0x00012] in <5a7d391011b47c3aa745038310397d5a>:0 
  at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Threading.Tasks.Task.Execute () [0x00010] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.AggregateException: One or more errors occurred. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path "/data/data/com.xamarin.live/files/External/.nuget/packages/system.threading.tasks.extensions/4.5.0-preview1-26216-02/ref/netstandard2.0/System.Threading.Tasks.Extensions.dll".
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0017d] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
  at System.IO.File.OpenRead (System.String path) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at <StartupCode$Continuous-Core-Droid>[email protected] () [0x00012] in <5a7d391011b47c3aa745038310397d5a>:0 
  at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Threading.Tasks.Task.Execute () [0x00010] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.IO.DirectoryNotFoundException: Could not find a part of the path "/data/data/com.xamarin.live/files/External/.nuget/packages/system.threading.tasks.extensions/4.5.0-preview1-26216-02/ref/netstandard2.0/System.Threading.Tasks.Extensions.dll".
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0017d] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
  at System.IO.File.OpenRead (System.String path) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at <StartupCode$Continuous-Core-Droid>[email protected] () [0x00012] in <5a7d391011b47c3aa745038310397d5a>:0 
  at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Threading.Tasks.Task.Execute () [0x00010] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 <---
<---

Failed to debug your app.

Assuming there is a dependency issue with the Microsoft.AspNetCore.SignalR.Client client?

@analogrelay
Copy link
Contributor

Looks closely related to #1518. We'll investigate over there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants