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

Xamarin - System.MissingMethodException - 'Microsoft.AspNetCore.SignalR.Client.HubConnectionExtensions.InvokeAsync' not found #1091

Closed
Kevvix opened this issue Nov 5, 2017 · 10 comments

Comments

@Kevvix
Copy link

Kevvix commented Nov 5, 2017

Hi,

I have create a Xamarin Forms solution with 4 projets :

  • Client.DataAccess (for my data access layer using SignalR to communicate with Server)
  • Client (the UI and VM for the Xamarin Forms)
  • Client.Android (application Android)
  • Client.UWP (application universal Windows Plateform)

Client have Client.DataAccess has reference
Client.Android have Client has reference
Client.UWP have Client has reference

The Client.DataAccess and Client projects target netstandard2.0.
the Client.DataAccess use this two packages :

  • "Microsoft.AspNetCore.SignalR.Client" version "1.0.0-alpha2-final"
  • "Microsoft.AspNetCore.SignalR.Client.Core" version "1.0.0-alpha2-final"

The UWP version of the Xamarin application work without a problem.
The Android version crash went trying to evaluation this method :

 private async Task CreateConnection(string token, AuthentificationProvider provider)
 {
            _server = new HubConnectionBuilder()
                    .WithUrl("http://192.168.2.14:50050/services")
                    .WithMessagePackProtocol()
                    .WithConsoleLogger(LogLevel.Debug)
                    .Build();
            await _server.StartAsync();
            var temp = await _server.InvokeAsync<Guid?>("Authenticate", token, provider); 
}

I got the error :
System.MissingMethodException: Method 'Microsoft.AspNetCore.SignalR.Client.HubConnectionExtensions.InvokeAsync' not found.

look like the method extension method "InvokeAsync" is not found at runtime.
I try to add the reference directly in the packages.config to this two packages but the error still persist.
the Client.Android project have reference to "NETStandard.Library" package.

thank for your help :)
sorry for my English.

@moozzyk
Copy link
Contributor

moozzyk commented Nov 6, 2017

Can you share a minimal repro as a github repo? This seems like a package version mismatch (i.e. using the alpha1 Microsoft.AspNetCore.SignalR.Client.Core somewhere but from your description it seems you are using the correct version). As a side note - you don't need to bring Microsoft.AspNetCore.SignalR.Client.Core package explicitly. The right version should be installed for you automatically when you add a reference to the Microsoft.AspNetCore.SignalR.Client package.

@Kevvix
Copy link
Author

Kevvix commented Nov 8, 2017

Hi Moozzyk, thank for your reply, help and time. The problem was my fault, I make a mistake with the reference, now my solution have only one reference to the package "Microsoft.AspNetCore.SignalR.Client" inside the "Client.DataAccess" (netstandard2) and everything work 👍 . Thanks also for your side note about the other package, I have remove him.

@Kevvix Kevvix closed this as completed Nov 8, 2017
@atefboujday
Copy link

Hello @Kevvix
I tried to create the same project, but my android application crash on run with following error:
F/monodroid-assembly(16655): Could not load assembly 'System.Memory' during startup registration.
F/monodroid-assembly(16655): This might be due to an invalid debug installation.
F/monodroid-assembly(16655): A common cause is to 'adb install' the app directly instead of doing from the IDE.
referenceTable GDEF length=814 1
referenceTable GSUB length=11364 1
referenceTable GPOS length=47302 1

Can you help me please

@analogrelay
Copy link
Contributor

@atefboujday Can you post some additional information? What version of Xamarin are you using and what SignalR packages (ID and version) are you using? That will help us to reproduce your issue and see if we can figure out what's wrong.

@atefboujday
Copy link

atefboujday commented Jan 11, 2018

@anurse Using this #1238 , i can execute my application.

Now I have a two questions. When i generate the apk. The application can't connect to the hub:
1- How we can do the copy in the post build event
I added the command (I put the two dll in a folder "Dlls")
start xcopy /Y /R "$(SolutionDir)\SignalRMobile\Dlls*.dll" "$(ProjectDir)\obj\Debug\android\assets"
But i have the error (Unable to create directory "obj\Debug\android\assets")
2- When i create the Apk File, i can't connect to the hub connection

I'm using:
VS 2017 15.5.3
Microsoft.AspNetCore.SignalR.Client 1.0.0-alpha2-final

@analogrelay
Copy link
Contributor

What error are you getting from the client? Have you tried any of the Troubleshooting Steps ? If those don't work, can you enable client and server tracing and post your logs?

@atefboujday
Copy link

atefboujday commented Jan 12, 2018

@anurse
1- My Code is just containing a function SignalR()
public static class MyHub
{
public static HubConnection _HubConnection { get; set; }

    public static async void SignalR()
    {
        try
        {
            string _Token = "*****";
            string _ServerUrl = "http://****";
            _HubConnection = new HubConnectionBuilder()
                                   .WithUrl(String.Format("{0}{1}{2}", _ServerUrl, "?token=", _Token))
                                   .WithConsoleLogger()
                                   .Build();
            
            await _HubConnection.StartAsync();

        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message.ToString());
        }

    }
}

2- I called this function from App.xaml.cs
public App ()
{
InitializeComponent();

		MainPage = new ProjectMobile.MainPage();

        //Initialize hub connection. 
        MyHub.SignalR();
    }

1- The build event is working now on Debug mode with linking option = "None"
2- When i create an apk, and install it on my mobile, the application does not start hub connection.
3- When i modify linking to "Sdk and User assemblies", Clean and rebuild my android project. After i run my project i have a crash and the following exeption:

Exception.txt
InnerException.txt

Thanks

@analogrelay
Copy link
Contributor

Oops, the links I referenced above were for the older version of SignalR and I got a little confused as to which version you were using :).

@mikaelm12 can you take a look when you've got some Xamarin things set up?

@atefboujday What version of SignalR are you using? Are you able to try using the latest builds from our nightly feed (if you aren't already) and see if they fix the issue?

@atefboujday
Copy link

Hi @anurse ,
Now I'm using:
1- For the server
Microsoft.AspNetCore.All 2.
0.3
Microsoft.AspNetCore.SignalR 2.1.0-preview1-27884
2- For the client Microsoft.AspNetCore.SignalR.Client 2.1.0-preview1-27884

When I run my android project, i never have a ConnectionId

Output.txt

@BrennanConroy
Copy link
Member

You don't get a ConnectionId on the client if you explicitly connect with WebSockets

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

5 participants