.net-standard

.NET Core - The reference assemblies for framework “DNXCore,Version=v5.0” were not found

瘦欲@ 提交于 2019-12-12 02:37:46
问题 I'm getting this error when migrating a .NET core lib (DNXCore50) from VS 2015 to VS 2017. The reference assemblies for framework " DNXCore ,Version=v5.0" were not found. My project file currently looks like this: (after the VS 2017 migration wizard migrated my "project.json" to a .csproj file) <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <Description>An FTP and FTPS library for .NET, optimized for speed. Provides extensive FTP commands, file uploads/downloads, SSL/TLS connections and

System.PlatformNotSupportedException: System.Data.SqlClient is not supported on this platform

断了今生、忘了曾经 提交于 2019-12-11 17:07:55
问题 I want to call a .netstandard2.0 library from a framework 4.7.2 library. I set up some test projects to check whether this would work. The test passes using a .Net Core 2.1 test project but fails with a framework 4.7.2 test project. The call stack is Test method UnitTestProject3.UnitTest1.TestMethod1 threw exception: System.PlatformNotSupportedException: System.Data.SqlClient is not supported on this platform. at System.Data.SqlClient.SqlConnection..ctor(String connectionString) at Microsoft

NewtonSoft.Json NuGet v11.0.1-beta3 not working with .Net Standard 2.0

可紊 提交于 2019-12-11 15:29:53
问题 Using Visual Studio 2017 15.5.5, I created a .NET Standard (2.0) Class Library. To this, I added the NuGet package "Newtonsoft.Json v11.0.1-beta3" (the latest full version does not seem to support .NET Standard 2.0). When I go to the package location, I see the following file: ~.nuget\packages\newtonsoft.json\11.0.1-beta3\lib\netstandard2.0\Newtonsoft.Json.dll However, when executing the code (in RELEASE mode only), I get the following exception: System.IO.FileNotFoundException : Could not

What's the equivalent to PropertyInfo.ReflectedType in .NET Core / .NET Standard?

怎甘沉沦 提交于 2019-12-11 07:28:31
问题 I need something like what PropertyInfo.ReflectedType does in the full framework. For now I've been not able to figure out what can be the alternative to the whole property of PropertyInfo . 回答1: ReflectedType is not supported in .NET Core and was "intentionally excluded" as guys from Microsoft says. This question on github contains a link to blog that explains the reason but is broken right now... You may look on PRs like Nunit. Eliminate use of ReflectedType in preparation for ASP .Net 5

How do I make catching generic IOExceptions reliably portable across platforms?

折月煮酒 提交于 2019-12-11 07:06:10
问题 I was trying to make the below code work on .NET Standard 1.5, which implies it should be portable across all platforms .NET Standard 1.5 supports. try { channel = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite); } catch (IOException e) when ((e.HResult & 0xFFFF) == 0x00000020) // ERROR_SHARING_VIOLATION { // no failure reason to be recorded, since this is the expected error if a lock exists } catch (IOException e) { FailureReason = e; } catch

stack trace from the current location in .NET Core

↘锁芯ラ 提交于 2019-12-11 07:02:36
问题 How can I constructs a stack trace from the current location? In .NET 4.5 works this solution: System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(true); for (int i = 0; i < stackTrace.FrameCount; ++i) { System.Diagnostics.StackFrame frame = stackTrace.GetFrame(i); MethodBase callerMethod = frame.GetMethod(); ... } But what is the solution in .NET Core? The constructor public StackTrace(bool fNeedFileInfo) does not exists anymore. 回答1: UPDATE .NET Standard 2.0 has

How to determine the .NET platform that runs the .NET Standard class library?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 06:45:48
问题 .NET Standard Library — One library to rule them all. The .NET Standard Library functionality may vary depending on the .NET platform that runs it: .NET Framework .NET Core Xamarin How to check the .NET platform where the .NET Standard library currently runs? For example: // System.AppContext.TargetFrameworkName // returns ".NETFramework,Version=v4.6.1" for .NET Framework // and // returns null for .NET Core. if (IsNullOrWhiteSpace(System.AppContext.TargetFrameworkName)) // the platform is

How to use SecureStringToBSTR in .net standard? (convert SecureString to IntPtr)

天涯浪子 提交于 2019-12-11 06:19:56
问题 I would like to convert a SecureString to an IntPtr. Until now, in .net 4.7 I was using this way: try { IntPtr bstr1 = IntPtr.Zero; bstr1 = Marshal.SecureStringToBSTR(ss1); } finally { if (bstr2 != IntPtr.Zero) Marshal.ZeroFreeBSTR(bstr2); if (bstr1 != IntPtr.Zero) Marshal.ZeroFreeBSTR(bstr1); } But I am trying to convert this project to .net standard 1.6, but the method is not available in Marshal type. So I would like to know how to convert the SecureString to IntPtr in .net standard.

Xamarin.Forms show a different datatemplate for a specific item in listview

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 05:24:23
问题 I'm currently developing a dynamic app using Xamarin.Forms with .Net Standard. I am using MVVM as code pattern. No code behind the view. The content of the view/page is a listview bound to a list of TemplateItem objects. Every listview item, TemplateItem , should look the same (as an article). But when the property BlockType of the TemplateItem is slideshow , the listview must look different by using another data template. How can I use another data template for a listview item when a

How to setup a NuGet package to copy content files to output build directory?

百般思念 提交于 2019-12-11 05:18:29
问题 NOTE: follow up from this question (now closed), as that one was too broad in scope, and the first part of that question, regarding .dlls, has been resolved, and this is a separate issue. I'm working on a .NET Standard 2.0 project called ComputeSharp that I'd like to publish as a NuGet package, but I can't figure out how to have the package copy a content file to the output build directory of a project using it. Some info: The project only targets .NET Standard 2.0 The project uses 2