.net-standard

HttpContext in .net standard library

跟風遠走 提交于 2019-12-18 14:48:11
问题 I am working on couple of projects one of which is an ASP.NET 4.5 application and other one is .Net Core API 1.1 project. The asp.net application is using HttpContext classes to read cookies and page headers. Now, I need to move this to a .net standard library which can be used by both the project. I don't find HttpContext in .net standard SDK. Any suggestions? 回答1: There's a problem to your approach: .NET Standard is the most bare-bones implementation of .NET available, meaning that only

Is EF Core Add Migration Supported from .NET Standard Library?

陌路散爱 提交于 2019-12-18 11:52:59
问题 We have been trying to run EF Core Migration in .Net Standard 1.6 class library, but it has been failing. But same passes very well in .Net Core 1.1 class library. Is EF Migration supported in .NET STANDARD? 回答1: The documentation covers this case as know issue/limitation when the DbContext is placed inside an netstandardx.y Class Library. Workaround 1 - Use an app as the startup project If you have an existing .NET Core App or .NET Framework App (including an ASP.NET Core Web Application),

Running .NET Standard binaries on different frameworks

六眼飞鱼酱① 提交于 2019-12-18 08:45:29
问题 I understand targeting .NET Standard 2 means that the frameworks between .net core, mono and the full .net framework, but I'd like to understand what that means for the binaries created by the different frameworks. So if I create a console program targeting .NET Standard 2 and compile using .NET Framework, can only the full .NET Framework run this file? If they can all run the files, how would I run the .NET Core .dll executable console using the full framework or Mono? So basically are the

Disable transitive project reference in .NET Standard 2

我们两清 提交于 2019-12-18 04:21:48
问题 I'm writing an MVC website using ASP.NET Core 2.0. In the ASP.NET Core project (let's call it Web ), I reference a .NET Standard 2 project in the same solution (let's call it Service ). The Service project also references a third .NET Standard 2 library in the solution (let's call this one Business ). The Business project declares a type called Model . The problem is that I can use Model in the Web project (i.e. the compiler sees the type Model and I can do var a = new Model(); ) as if the

Disable transitive project reference in .NET Standard 2

有些话、适合烂在心里 提交于 2019-12-18 04:21:47
问题 I'm writing an MVC website using ASP.NET Core 2.0. In the ASP.NET Core project (let's call it Web ), I reference a .NET Standard 2 project in the same solution (let's call it Service ). The Service project also references a third .NET Standard 2 library in the solution (let's call this one Business ). The Business project declares a type called Model . The problem is that I can use Model in the Web project (i.e. the compiler sees the type Model and I can do var a = new Model(); ) as if the

New .csproj format - How to specify entire directory as “linked file” to a subdirectory?

早过忘川 提交于 2019-12-18 04:01:53
问题 With the new .csproj format (as well as the old), it is possible to add files as linked outside of the project folder: <EmbeddedResource Include="..\..\..\Demo\Sample.cs" Link="Resources\Sample.cs" /> It is also possible to use a glob pattern to include multiple files: <EmbeddedResource Include="..\..\..\Demo\*.cs" /> But how do you combine the two? What I Tried <EmbeddedResource Include="..\..\..\Demo\*.cs" Link="Resources\*.cs" /> <EmbeddedResource Include="..\..\..\Demo\*.cs" Link=

Adding a bindingRedirect to a .Net Standard library

╄→尐↘猪︶ㄣ 提交于 2019-12-18 02:09:28
问题 I have a .Net Standard library, and I'm getting an error when trying to use one of the dependant libraries, which I believe is down to a version conflict. In an old style .Net Class library, I might add something like this: <?xml version="1.0" encoding="utf-8"?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0

Using .net standard 1.5 lib in .net 4.6.2 misses System.Runtime 4.1.0.0

荒凉一梦 提交于 2019-12-17 11:53:51
问题 I've some problem when using .net standard in .net framework 4.6.2 consoleapps. I could reduce the problem to this: Given: I create a .net standard 1.5 client library vis vs 2017 with this single class public class Class1 { public List<int> Get() { return new List<int>() { 1, 2, 3, 4, 5, 65, 6 }; } } Now I create a new .net 4.6.2 console application which is just calling the method of this class: static void Main(string[] args) { var foo = new Class1(); Console.WriteLine("Done!"); Console

What is the difference between .NET Core and .NET Standard Class Library project types?

主宰稳场 提交于 2019-12-17 05:15:32
问题 In Visual Studio, there are at least 3 different types of class library you can create: Class Library (.NET Framework) Class Library (.NET Standard) Class Library (.NET Core) While the first is what we've been using for years, a major point of confusion I've been having is when to use the .NET Standard and .NET Core class library types. I've been bitten by this recently when attempting to multi-target different framework versions, and creating a unit test project. So, what is the difference

Does C# 8 support the .NET Framework?

你。 提交于 2019-12-17 04:26:39
问题 In Visual Studio 2019 Advanced Build settings, C# 8 does not appear to be available for a .NET Framework project, only (as in the picture below) for a .NET Core 3.0 project: Does C# 8 support the .NET Framework? 回答1: Yes, C# 8 can be used with the .NET Framework and other targets older than .NET Core 3.0/.NET Standard 2.1 in Visual Studio 2019 (or older versions of Visual Studio if you install a Nuget package). The language version must be set to 8.0 in the csproj file. Most - but not all -