.net-standard

Could not load file or assembly 'System.Security.Cryptography.Algorithms, Version = 4.1.0.0

喜你入骨 提交于 2019-12-10 13:49:53
问题 I'm trying to use System.Security.Cryptography.RNGCryptoServiceProvider class in my .NET Standard 1.4 library and according to this topic my code looks like this: private byte[] GenerateRandomNumber(int length) { using (var randomNumberGenerator = RandomNumberGenerator.Create()) { var number = new byte[length]; randomNumberGenerator.GetBytes(number); return number; } } I have also installed from NuGet libraries: System.Security.Cryptography.Algorithms v=4.3.0 System.Security.Cryptography

Reference a .NETStandard 2.0 project from UWP project

浪尽此生 提交于 2019-12-10 12:44:59
问题 I am building a Xamarin application, and I have implemented the core (using Xamarin.Forms) in a .NETStandard 2.0 class library. It is correctly referenced by an iOs and Android project which implements the platform-specific code. The problem is, I tried to add an UWP project in order that my app supports UWP, and when I try to reference the core project, I have the following error: Project [Core project] is not compatible with uap10.0.10586 (UAP,Version=v10.0.10586) / win10-x86-aot. Project

“Could not load file or assembly” error when net462 app references a netstandard1.5 library. But why?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 11:03:23
问题 I am trying to figure out what I could be doing wrong in this sample project. I am getting an error when my net462 application references a netstandard1.5 library. The application has a dependency on "System.Collections.Immutable": "1.3.0" , which targets NetStandard 1.0 according to Nuget. The library depends on "NETStandard.Library": "1.6.0" . Am I setting up either of these projects wrong? I would greatly appreciate any insight on this... Here are their project.json : app: { "buildOptions"

Missing Method Exception When Referencing .Net Standard Project From .Net 4.6.1 Unit Test

荒凉一梦 提交于 2019-12-10 02:44:55
问题 I am getting the following exception when running a .Net 4.6.1 unit test that uses System.IO.Compression.ZipFile.Open , if the unit test project references a .Net Standard 2.0 assembly: System.MissingMethodException: Method not found: 'System.IO.Compression.ZipArchive System.IO.Compression.ZipFile.Open(System.String, System.IO.Compression.ZipArchiveMode)'. at UnitTestProject.UnitTest1.TestMethod1() The unit test project was created using the VS 2017 Unit Test project (not the .NET Core one)

Alternatives of CompileToMethod in .Net Standard

北城余情 提交于 2019-12-10 00:58:01
问题 I'm now porting some library that uses expressions to .Net Core application and encountered a problem that all my logic is based on LambdaExpression.CompileToMethod which is simply missing in. Here is sample code: public static MethodInfo CompileToInstanceMethod(this LambdaExpression expression, TypeBuilder tb, string methodName, MethodAttributes attributes) { ... var method = tb.DefineMethod($"<{proxy.Name}>__StaticProxy", MethodAttributes.Private | MethodAttributes.Static, proxy.ReturnType,

.NET Standard 2.0 cannot be referenced in .NET Framework 2.0

只谈情不闲聊 提交于 2019-12-08 19:49:59
问题 I received an error: 'c:......\xxxx.csproj' targets '.NETStandard,Version=v2.0'. It cannot be referenced by a project that targets '.NETFramework,Version=v2.0'. WindowsFormsApp1 How to resolve? 回答1: Unfortunately you cannot reference a .NET Standard library in .NET 2.0 project. The reason is that .NET 2.0 is missing many key API and hence cannot implement the .NET Standard 2.0 contract. If you cannot modify the source of the .NET Standard 2.0 library, the only option is upgrading your project

ASP.NET Web API 2 cannot return stream when NET Standard 1.6 project is referenced

二次信任 提交于 2019-12-08 13:43:31
This is one of the weird issue I have seen and here are the steps to reproduce 1> Create new Web API project in VS 2017 with Target Framework 4.6.2 Create new ASP.NET Web Application -> Select Empty -> Check Web API -> Click OK 2> Add Controller that returns a Stream public class ReportController : ApiController { [HttpGet] public HttpResponseMessage Download() { var filePath = "C:\\Report.xlsx"; var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read); var result = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StreamContent(fs) }; result.Content.Headers.ContentType = new

ASP.NET Web API 2 cannot return stream when NET Standard 1.6 project is referenced

对着背影说爱祢 提交于 2019-12-08 07:40:39
问题 This is one of the weird issue I have seen and here are the steps to reproduce 1> Create new Web API project in VS 2017 with Target Framework 4.6.2 Create new ASP.NET Web Application -> Select Empty -> Check Web API -> Click OK 2> Add Controller that returns a Stream public class ReportController : ApiController { [HttpGet] public HttpResponseMessage Download() { var filePath = "C:\\Report.xlsx"; var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read); var result = new

Microsoft.AspNet.Identity and Microsoft.AspNet.Identity.EntityFramework in .NET Standard 2.0

ⅰ亾dé卋堺 提交于 2019-12-07 21:12:45
问题 Background: The project we are wokring on consists of several solutions that share two libraries . Everything is written in .NET Framework 4.6.1 today. A goal for the project has been to adopt .NET Core for new projects and being able to run web applications in Docker . With the new release of .NET Standard 2.1 and the fact that .NET Framework 4.8 will remain on .NET Standard 2.0 rather than implement .NET Standard 2.1 it felt like the right time to start. Immo Landwerth from Microsoft says

Error for .NETStandard1.6 PCL: “Your project is not referencing the ”.NETPlatform,Version=v5.0“ framework”

对着背影说爱祢 提交于 2019-12-07 08:49:25
问题 To help reproduce the problem, the following steps are taken to create a .NETStandard1.6 PCL in Visual Studio 2015: Create a new Class Library(Portable for iOS, Android and Windows). In its Properties page, click "Target .NET Platform Standard". Change .NETStandard form .NETStandard1.1 to .NETStandard1.6 Build this empty project. The following error occurs: >C:\Program Files (x86)\MSBuild\Microsoft\NuGet\Microsoft.NuGet.targets(140,5): error : Your project is not referencing the ".NETPlatform