.net-core

The reference assemblies for framework .NETCore, Version=v5.0 were not found

懵懂的女人 提交于 2021-02-07 12:29:24
问题 I have a UWP project that was created using Visual Studio 2017. It builds fine on this machine (machine 1). However, when I copy the project over to a machine (machine 2) where I only have the Visual Studio 2017 Build Tools installed, and attempt to build it using MSBuild, I get the following error: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets (1126,5): error MSB3644: The reference assemblies for framework ".NETCore

IHttpContextAccessor Session GetString

安稳与你 提交于 2021-02-07 11:38:12
问题 I'm trying to migrate an ASP.NET MVC site to ASP.NET Core with the .NET Core runtime. Previously we could get objects out of the session store, even in different assemblies, with var obj = HttpContext.Current.Session[key] Now I've read we must inject IHttpContextAccessor and use the method on _contextAccessor.HttpContext.Session. But the methods of the Session object have changed, and it no longer has indexing applied. I have seen people in other questions using HttpContext.Session.GetString(

BeginInvoke not supported on .NET core? (PlatformNotSupported exception)

梦想的初衷 提交于 2021-02-07 11:17:44
问题 I've ported a library FluentFTP to .NET standard/.NET core but the async methods use BeginInvoke within an async/await block. So its something like this: async ConnectAsync(){ BeginConnect(); } void BeginConnect(){ BeginInvoke(...) << error at this point } At that point I get a PlatformNotSupported exception. What can be done to support this on .NET core? Full info here. Full code here: ConnectAsync, BeginConnect. 回答1: Asynchronous I/O methods should not use Delegate.BeginInvoke . That's

Passing bytes by reference from C# into C++/CLI wrapper to call the InterlockedOr8 function

白昼怎懂夜的黑 提交于 2021-02-07 10:54:47
问题 I am trying to pass bytes by reference from C# such that I can call the atomic operation InterlockedOr8 on them. I have the following static library in C++: Bitwise.h : char EightBitOr(char volatile* destination, char value); Bitwise.cpp : #include "Bitwise.h" char EightBitOr(char volatile* destination, char value) { return InterlockedOr8(destination, value); } I am calling it from this C++/CLI wrapper DLL: Wrapper.h : #include "..\Bitwise\Bitwise.h" using namespace System; namespace Wrapper

Passing bytes by reference from C# into C++/CLI wrapper to call the InterlockedOr8 function

空扰寡人 提交于 2021-02-07 10:54:32
问题 I am trying to pass bytes by reference from C# such that I can call the atomic operation InterlockedOr8 on them. I have the following static library in C++: Bitwise.h : char EightBitOr(char volatile* destination, char value); Bitwise.cpp : #include "Bitwise.h" char EightBitOr(char volatile* destination, char value) { return InterlockedOr8(destination, value); } I am calling it from this C++/CLI wrapper DLL: Wrapper.h : #include "..\Bitwise\Bitwise.h" using namespace System; namespace Wrapper

VSTS dotnet Nuget Pack: Is not a valid version string

若如初见. 提交于 2021-02-07 10:36:36
问题 I am trying to create a prerelease build for a .net-standard 2.0 library in VSTS. I have created a build with the following steps dotnet restore version 2 dotnet build version 2 dotnet pack version 2 nuget push version 2 When I use the environment variable (PackageName) as $(Build.BuildNumber)-beta as my pack version. The pack fails with the error BuildName_2018.7.11.1-beta is not a valid version string . I have previously used this environment variable as my pack version in .net-framework

Have a NuGet package output a file

不想你离开。 提交于 2021-02-07 10:36:33
问题 I have a Visual Studio project that I have made into a NuGet package. The project has a file in it (called SwaggerIndex.html ). I have set that file to have the "Copy to Output Directory" property to "Copy if newer". (I need this file to copy to the build folder on build.) In that solution it works just fine. (I created another project to test it, and when it references my project that has the SwaggerIndex.html , it outputs it to the build folder just fine.) However, when I package it into a

How to bind a multipart/form-data file without filename to IFormFile in ASP.NET Core

让人想犯罪 __ 提交于 2021-02-07 10:11:39
问题 In a simple controller action in ASP.NET Core 3.1 that accepts multipart/form-data parameters: using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace WebApplication { public class Controller : ControllerBase { [HttpPost("length")] public IActionResult Post([FromForm] Input input) { if (!ModelState.IsValid) return new BadRequestObjectResult(ModelState); return Ok(input.File.Length); } public class Input { [Required] public

WCF Change message encoding from Utf-16 to Utf-8

江枫思渺然 提交于 2021-02-07 10:10:58
问题 I have a WCF connected service in a .net core application. I'm using the code that is autogenerated taken the wsdl definition. Currently at the top of the request xml is including this line: <?xml version="1.0" encoding="utf-16"?> I can't find a simple way to change this encoding to UTF-8 when sending the request. Since I could find a configuration option a the request/client objects, I've tried to change the message with following code at IClientMessageInspector.BeforeSendRequest public

WCF Change message encoding from Utf-16 to Utf-8

淺唱寂寞╮ 提交于 2021-02-07 10:10:45
问题 I have a WCF connected service in a .net core application. I'm using the code that is autogenerated taken the wsdl definition. Currently at the top of the request xml is including this line: <?xml version="1.0" encoding="utf-16"?> I can't find a simple way to change this encoding to UTF-8 when sending the request. Since I could find a configuration option a the request/client objects, I've tried to change the message with following code at IClientMessageInspector.BeforeSendRequest public