how to start working on xamarin with signalr - signalr

I'm new to both Xamarin and SignalR. While I'm able to easily follow the tutorials for SignalR on Visual Studio, and get a sample chat application working, I'm not able to make it work on Xamarin. I tried to reference the signalr assemblies in Xamarin, but it fails with the following error -
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2): Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Security, Version=4.0.0.0, Culture=neutral
But I'm not able to find System.Security to add to references.
Am I doing this right?
I also tried looking for SignalR in Components. But couldn't find it.
Also, I tried to find some tutorials on SignalR in Xamarin that would guide me through this process. But I wasn't able to find any. Can someone point me to some blogs/tutorials that can help me setup SignalR in Xamarin?
Thanks!

These steps worked for me:
Installed the beta updates on Xamarin
Got the dev branch on signalr and built it to include mono support
Removed reference to signalr.core assembly (this was the one referencing system.security)

If you are on Xamarin.Forms Net standard
(https://blog.xamarin.com/building-xamarin-forms-apps-net-standard/), just install nuget 'Microsoft.AspNet.SignalR.Client' and use all sample code provided by microsoft for NET client (https://learn.microsoft.com/en-us/aspnet/signalr/overview/guide-to-the-api/hubs-api-guide-net-client) into your shared code.

Related

How can I trace failed assembly binding in a dotnet core web project (running in IIS Express)

I'm struggling to find why a certain assembly is not loaded in a dotnetcore 3.1 webproject
(I'm getting Could not load file or assembly 'MyCool.Services.Interfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null')
If this was a netFw project I would simply fire up Fuslogvw and find a lot of information about why the assembly binding fails.
Maybe I've overlooked, but I haven't found an alternative way to find this kind of information for a dotnet core project.
A previous post asked it here but doesn't have an answer :
What's the replacement for fuslogvw in .net core 2?
I also already followed the advice of this SO post : Inspect dependencies for dynamically loaded library in .net core and set COREHOST_TRACE=1 in the package manager console.
But it seems it's not useful for web projects running is IIS express.. (the log states dotnet : Couldn't find a project to run. while I have my project started)
Any advice on how the trace my failed assembly binding would be much appreciated !
Ok, a bit more perseverance in Googling helped me out....
It turns out that Microsoft has already given us a new "dotnet-trace analysis utility" and a ton of documentation on how to trace assembly loading.
Steps to use this are :
Install the dotnet-trace utility using dotnet tool
PM> dotnet tool install --global dotnet-trace
Identify the pid of your running application in iis express
PM> dotnet-trace ps
Start tracing :)
PM> dotnet-trace collect --providers Microsoft-Windows-DotNETRuntime:4
--process-id <pid>
Finally open the trace.nettrace file with the perfview tool from Github/microsoft/perfview
I hope this info helps others in not loosing too much time googling around for "how to fuslogvw in dotnetcore" :)

Having trouble referencing .NET Standard class library using SQLProvider from .NET Core project

Reproduction of problem here: https://github.com/Arrow7000/SqlProviderTest
I'm fairly new to the .NET world so am having trouble wrapping my head around exactly what the problem is.
I've tried to use the SQL type provider directly in an F# .NET Core project, but had a bunch of problems getting it to work. From what I can tell that's due to incompatibilities between .net core and type providers.
So what I am trying instead is to have the SQL type provider code encapsulated in a .NET Standard project that I can reference from my main Core project.
I've managed to reproduce the problem in a minimal GitHub repo located here which demonstrates both that
the type provider is working in Visual Studio 2019 with IntelliSense, but
despite this I still get a build error when I try to start the Main project
The build error is
Unable to find the file 'C:\projects\SqlProviderTest\SQLStuff\bin\Debug\netstandard2.0\SQLStuff.dll' in any of
C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\ref\netcoreapp2.2
C:\projects\SqlProviderTest\Main
C:\Users\Aron\.nuget\packages\fsharp.core\4.6.2\lib\netstandard1.6
Why isn't the project reference simply working as expected? I've tried adding <Private>True</Private> to the project reference but that didn't make any difference
P.S. in case it matters, I'm developing on Windows but the app gets deployed on a Docker container.

ADAL 3.17.3 with Xamarin.Forms

i can't figure out how to create a project with Xamarin that use ADAL for authentication.
Visual Studio 2017
ADAL 3.17.3
Xamarin Shared Project or .NET standard, for me is the same, i even haven't understand what is needed for ADAL to work.
Latest updates in place.
Anyone got a good link for a tutorial or just any suggestion?
Pls note, iv'e tried something like 4, 5 tutorials, no one work. With shared project on android it says that can't load some part of the dlls, on .NET standard, the project won't compile at all.
All tutorials i've found were posted at least one year ago, when the ADAL was not just relaeased but on the preview channel.
Thank you guys!
I suggest that you have a look at this sample:
https://github.com/azure-samples/active-directory-dotnet-native-multitarget
If you are using a PCL library that consumes ADAL.NET be sure to also reference ADAL.NET in your Xamarin.Android project to be sure that the right DLL is picked-as the NuGet package supports several platforms as explained here

Attempt by method 'HttpConfiguration..ctor(HttpRouteCollection)' to access method 'HttpConfiguration.DefaultFormatters()' failed

I have a Web API that has version 5.1.2 of the Microsoft.AspNet.WebApi.Client package installed.
I am trying to access the API from an ASP.NET MVC application, which also has the same version of the package installed.
However, in the Global.asax of the Web API project, on the line below, I get the following exception:
WebApiConfig.Register(GlobalConfiguration.Configuration);
Attempt by method 'System.Web.Http.HttpConfiguration..ctor(System.Web.Http.HttpRouteCollection)' to access method 'System.Web.Http.HttpConfiguration.DefaultFormatters()' failed.
I found that this error occurs when you have multiple projects pointing to different .net versions.
For example if you have a Web API project targeting .net 4.5 and a unit test project targeting .net 4.5.3 it seems that default settings mean nuget may silently update the .net 4.5 project references to incompatible versions one day when you open visual studio and cause your Web API project to fail with the recondite 'Attempt by method 'HttpConfiguration..ctor(HttpRouteCollection)' to access method 'HttpConfiguration.DefaultFormatters()' failed' error.
To avoid the error drop the higher .net version back on the new project to match the Web API project - for this example right click the unit test project, click properties, then change the target framework to .net framework 4.5.
In my case it was a discrepancy between versions of Microsoft.AspNet.WebApi.Client and Microsoft.AspNet.WebApi.Core, I tried updating both to the same version and it worked.
In my case, the issue was solved when I installed the Microsoft.AspNet.WebApi.Core as well. So three libraries should present and be in harmony (uninstall / install) Microsoft.AspNet.WebApi.Client, Microsoft.AspNet.WebApi.Core and Newtonsoft.json
same for the above answers in my case also it is working good after updating or reinstalling packages
Microsoft.AspNet.WebApi.Client
Microsoft.AspNet.WebApi.Core

Build Fails After Changing Configuration to Release

I would like to start using the web.config transform feature in Visual Studio when publishing to our test and production site. However, the release build fails while the debug build works fine.
I've believe I'm made the build settings the same. Although the only differences were 'Enable DEBUG constant', 'Enable optimizations', and 'Generate debug info'.
Anyway, the build error is "Could not load file or assembly 'file:...dll' or one of it's dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515).
The mentioned dll was from the Ajax Control Toolkit. I used Nuget to 'install' the Ajax Control Tookit package instead of just including a reference to the dll. Then I got the same error for Microsoft's AntiXSS. So I again used Nuget to 'install' AntiXSS. Unfortunately, now I'm getting this error on another third party API that doesn't have a Nuget installer. Also, I'm getting this error on a dll I've created that I include in a number of projects here.
Does someone know what is causing this error? What should I do to fix this error? Do I need to create a Nuget package?
Thanks

Resources