Azure function SDK Causing Newtonsoft issue - c#

We are using azure function SDK in visual studio 2017 in .Net Frame work 4.6. We have added nuget packages
Microsoft.Azure.Devices.Shared 1.15.1
Newtonsoft.Json 12.0.1
AzureFunctions.Autofac 3.0.7 (for dependency injection )
when creating a instance of Twin we are getting a the following exception message
"message": "Could not load file or assembly 'Newtonsoft.Json,Version=10.0.0.0, > Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or
one of its dependencies. The system cannot find the file specified.",
We tried downgrading the package to
Newtonsoft.Json 10.0.1
Then we are getting the same error by replacing missing Newtonsoft.Json version 10.0.1 with Newtonsoft.Json version 12.0.1 .
this is the code we are following .
Twin updatetwin = new Twin();
updatetwin.ETag = "*";
var body = await RequestBody(req);
var newtwin =JsonConvert.DeserializeObject<PropertyViewModel>(body);

I am using
Newtonsoft.Json 9.0.1
with .net framework 4.6 and
Microsoft.NET.Sdk.Functions 1.0.13
You can check required dependencies in nuget package manager-

Related

Microsoft SqlServer Management: method not found creating a ServerConnection

Microsoft.SqlServer.SqlManagementObjects 161.47027.0
Microsoft.Data.SqlClient 5.0.0
After upgrading Microsoft.Data.SqlClient from 4.1.0 to 5.0.0
I got this error creating a ServerConnection object:
using Microsoft.SqlServer.Management.Common;
var serverConnection = new ServerConnection("localhost", "sa", "mypwd");
System.MissingMethodException: 'Method not found: 'Void
Microsoft.Data.SqlClient.SqlConnectionStringBuilder.set_Encrypt(Boolean)
It looks for a not implemented set_Encrypt method inside a Microsoft.Data.SqlClient.SqlConnectionStringBuilder
Does it mean Microsoft.SqlServer.SqlManagementObjects has not been updated yet to support Microsoft.Data.SqlClient 5.0.0?
If so do I need to wait for this update before I can upgrade Microsoft.Data.SqlClient 5.0.0 into my project?
You can also upgrade the ServerManagementObjects reference to 170.7.0-preview to resolve. Apparently the issue is with the smo library not the sqlclient library.
https://github.com/dotnet/SqlClient/issues/1702
Their code should be backwards compatible, but they need to be recompiled against MDS 5.0
Below is MyConnectionString"
"Server=tcp:xxx.xxxx.windows.net;Authentication=Active Directory Default;Database=TestDB;TrustServerCertificate=True;MultipleActiveResultSets=True;"
Had the error:
Method not found: 'Void Microsoft.Data.SqlClient.SqlConnectionStringBuilder.set_Encrypt(Boolean)'. When usingMicrosoft.Data.SqlClient 5.0.1.`
Fixed By: Downgraded the package Microsoft.Data.SqlClient to 4.1.0.and Using Microsoft.SqlServer.SqlManagementObjects 161.47021.0.
Fixed the error. Thank you for this post.
We had the same MissingMethodException when attempting the update of Microsoft.Data.SqlClient 4.1.0 to 5.0.0 in our system. Simply updating Microsoft.Data.SqlClient - independently of Microsoft.SqlServer.SqlManagementObjects - resulted in the exception when constructing the Microsoft.SqlServer.Management.Common.ServerConnection using SQL Server Authentication (not Windows Authentication).
This snippet causes the MissingMethodException if using Microsoft.Data.SqlClient 5.0.0 (worked in 4.1.0):
Return New ServerConnection With {
.ApplicationName = My.Application.Info.Title,
.ServerInstance = connectionParameters.DataSource,
.ConnectTimeout = connectionParameters.ConnectionTimeout,
.LoginSecure = False,
.Login = connectionParameters.UserName,
.Password = connectionParameters.Password
}
For now, we are holding off on updating Microsoft.Data.SqlClient, but went ahead with the Microsoft.SqlServer.SqlManagementObjects update (161.47021.0 to 161.47027.0). I am hopeful that an upcoming Microsoft.Data.SqlClient version will fix this issue.

Tests for Azure Table Storage using Microsoft.Azure.Storage.Common 9.4.0.2-preview

I created a .NET Standard 2.0 class library where I use Azure table storage as it's described here - https://learn.microsoft.com/en-us/azure/cosmos-db/table-storage-how-to-use-dotnet. Also, I created a .NET Core test project to test my client library. And when I run a simple test I get this:
System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.Azure.Documents.Client, Version=1.22.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
I tried many things to make it work but this is just waste of time. How do I fix this?
Microsoft.Azure.Documents.Client package is now obselete. Please use Microsoft.Azure.DocumentDB package instead.
Refer here
Nuget Console:
Install-Package Microsoft.Azure.DocumentDB.Core -Version 1.9.1
(Or)
Install-Package Microsoft.Azure.DocumentDB -Version 2.0.0-preview2
See more about this System.IO.FileNotFoundException : Could not load file or assembly error

VS2017 .NetCore 2.0 API - Could not load file or assembly Microsoft.AspNetCore.Hosting.Abstractions

I've just created a new API using ASP.NET Core 2.0.
I haven't coded anything yet. I just want to test the initial API template.
When I try to start my project I receive the following error:
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module.
Could not load file or assembly 'Microsoft.AspNetCore.Hosting.Abstractions, Version=2.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
I do not receive any errors when building the project.
The assemby can be found at the following directory: 'C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.hosting.abstractions\2.0.2'.
Is that correct? Where should the 'Microsoft.AspNetCore.Hosting.Abstractions' assembly be located and why can't VS find it?
I had the same error attempting to debug a simple Azure Function App (this is using .NET core) created from the Function App template in Visual Studio 2017. Attempting to run in debugger gave me the same error. It turned out to be I had updated the Microsoft.NET.Sdk.Functions package from version 1.0.6 to 1.0.12. That was my problem. Reverted the update back to 1.0.6 and it worked fine. Hope this helps!
Please re-install the nuget package or upgrade to the latest at: https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.Abstractions/

Xamarin.Firebase.Common not compatible with Xamarin.Firebase.Auth

I'm trying to install 'Xamarin.Firebase.Storage.42.1021.1' so I can upload photos to my firebase database
I'm targeting 'MonoAndroid, Version=v7.1'
However, when I try to install the package I get the following
Unable to find a version of 'Xamarin.Firebase.Common' that is compatible with 'Xamarin.Firebase.Auth 42.1024.0-beta1 constraint: Xamarin.Firebase.Common (= 42.1024.0-beta1)', 'Xamarin.Firebase.Storage 42.1021.1 constraint: Xamarin.Firebase.Common (= 42.1021.1)'.
Is there a quick fix without breaking my project?
You may checked the Dependencies of Xamarin.Firebase.Storage and Xamarin.Firebase.Auth.
According to your error message, you've installed the Xamarin.Firebase.Auth 42.1024.0-beta1 package, which needs dependency Xamarin.Firebase.Common (= 42.1024.0-beta1).
Try to downgrade your Xamarin.Firebase.Auth package to version 42.1021.1.

FileNotFoundException: Could not load

I'm working on a .net Core project, using the .net Core framework, I wanted to use DropNet package with .net Core so I added a reference to net452 framework inside my project.json:
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8",
"net452"
]
}
},
Now when I try to create a DropNet client object in my controller class I've got an error:
Error CS0012 The type 'IWebProxy' is defined in an assembly that is not referenced.
You must add a reference to assembly 'System, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'. Test3..NETCoreApp,Version=v1.0
Ok in order to fix that error I've installed microsoft.netcore.portable.compatibility package, and the error is gone, the thing is that when I do that and execute the project and try to get access to the View that I'm returning from the controller action where I'm using DropNet I get a FileNotFoundException :
FileNotFoundException: Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
I'm having that problem only with that view, this is my Action Method:
public IActionResult Test()
{
DropNetClient client = new DropNetClient("gsfgsgsfg438", "6ysgsgs234cf", userToken: "w5gdfgsdfg3434d4", userSecret: "239usfgsghsf3434wyqo");
return View();
}
The problem is that DropNetClient line, if a comment that line, the view is showed, but if that line is active in there, the FileNotFoundException is thrown...
Please, don't abuse the import statement. It is there to override nuget validation when restoring packages, to install libraries which are compatible (PCL which target .NET 4.5 and Windows 8/8.1+) but do not yet have the netstandard1.6 target.
Don't EVER use it to force import net452 libraries into a .NET Core application. It won't work!!! .NET 4.5.2 libraries aren't compatible with .NET Core!!!
You only have two options:
Don't use any libraries which do not support netstandard, netcoreapp or portable-net45+win8!!!
If you need some libraries that only run with net452 and there is no replacement, then target net452 instead of netcoreapp1.0

Categories

Resources