.net-core

Is it possible to use BackgroundWorker class with .net core?

匆匆过客 提交于 2021-02-08 15:15:07
问题 I am trying to port a C# console project that works fine on Windows to Linux with .NET Core. I have created a project.json file, run dotnet restore and everything seems to work fine. But when I run dotnet build, I get this message : The type or namespace name 'BackgroundWorker' could not be found (are you missing a using directive or an assembly reference?) According to .NET Core API, the class BackgroundWorker seems to exist in System.ComponentModel. Here's my project.json : "version": "1.0

.NET Core Nancy application serving static files

折月煮酒 提交于 2021-02-08 15:13:51
问题 I am trying to build a minimal viable web site as a .NET Core project using Nancy with some backend processing and static files as frontend which resides in default project folder wwwroot . The main problem is I don't understand how to make the app respond with static files, because default conventions don't apply to the new .NET Core project system. Building Nancy applications as classic .NET Framework applications is well documented and there are many samples on the web on how to do it. But

Using Shared Libraries with .NET Core

孤者浪人 提交于 2021-02-08 15:13:47
问题 I wrote my open source library, LINQ to Twitter, with shared libraries to minimize deployment artifacts and handle platform specific features. I want to support .NET Core and am thinking that the fastest approach would be to reference the shared libraries. The Add References dialog didn't show the shared libraries, so I tried project.json: { "version": "1.0.0-*", "dependencies": { "NETStandard.Library": "1.6.0", "LinqToTwitter.Shared": "*", "LinqToTwitter.Shared.net": "*" }, "frameworks": {

Is it possible to use BackgroundWorker class with .net core?

最后都变了- 提交于 2021-02-08 15:13:25
问题 I am trying to port a C# console project that works fine on Windows to Linux with .NET Core. I have created a project.json file, run dotnet restore and everything seems to work fine. But when I run dotnet build, I get this message : The type or namespace name 'BackgroundWorker' could not be found (are you missing a using directive or an assembly reference?) According to .NET Core API, the class BackgroundWorker seems to exist in System.ComponentModel. Here's my project.json : "version": "1.0

Using Shared Libraries with .NET Core

南笙酒味 提交于 2021-02-08 15:11:30
问题 I wrote my open source library, LINQ to Twitter, with shared libraries to minimize deployment artifacts and handle platform specific features. I want to support .NET Core and am thinking that the fastest approach would be to reference the shared libraries. The Add References dialog didn't show the shared libraries, so I tried project.json: { "version": "1.0.0-*", "dependencies": { "NETStandard.Library": "1.6.0", "LinqToTwitter.Shared": "*", "LinqToTwitter.Shared.net": "*" }, "frameworks": {

Calling C# async method from F# results in a deadlock

六月ゝ 毕业季﹏ 提交于 2021-02-08 15:09:56
问题 I have a set of F# scripts that call various libraries that we have created, many of them exposing asynchronous methods originally written in C#. Recently I found out the scripts stopped working (I think it's about half a year since I used them last time and they worked back then). I was trying to isolate the problem and came up with the following code that reproduces it: First, let's consider a library containing the following C# class: public class AsyncClass { public async Task<string>

Additional probing paths for .NET Core 3 migration

感情迁移 提交于 2021-02-08 14:12:04
问题 Short version of the question: Is there any way in .NET Core 3 to specify a local probing path, using the same rules as the <probing> element from app.config? additionalProbingPaths does not seem to work. Long version of the question: I'm migrating a project from .NET Framework to .NET Core 3. In the original project, I kept a number of secondary dlls in a lib/ folder. This worked fine, as I set the probing path in App.exe.config , like so: <runtime> <assemblyBinding xmlns="urn:schemas

Additional probing paths for .NET Core 3 migration

天大地大妈咪最大 提交于 2021-02-08 14:10:18
问题 Short version of the question: Is there any way in .NET Core 3 to specify a local probing path, using the same rules as the <probing> element from app.config? additionalProbingPaths does not seem to work. Long version of the question: I'm migrating a project from .NET Framework to .NET Core 3. In the original project, I kept a number of secondary dlls in a lib/ folder. This worked fine, as I set the probing path in App.exe.config , like so: <runtime> <assemblyBinding xmlns="urn:schemas

Additional probing paths for .NET Core 3 migration

半世苍凉 提交于 2021-02-08 14:08:35
问题 Short version of the question: Is there any way in .NET Core 3 to specify a local probing path, using the same rules as the <probing> element from app.config? additionalProbingPaths does not seem to work. Long version of the question: I'm migrating a project from .NET Framework to .NET Core 3. In the original project, I kept a number of secondary dlls in a lib/ folder. This worked fine, as I set the probing path in App.exe.config , like so: <runtime> <assemblyBinding xmlns="urn:schemas

xunit - how to get HttpContext.User.Identity in unit tests

拜拜、爱过 提交于 2021-02-08 14:01:12
问题 I added a method to my controllers to get the user-id from the JWT token in the HttpContext . In my unit tests the HttpContext is null , so I get an exception. How can I solve the problem? Is there a way to moq the HttpContext ? Here is the method to get the user in my base controller protected string GetUserId() { if (HttpContext.User.Identity is ClaimsIdentity identity) { IEnumerable<Claim> claims = identity.Claims; return claims.ToList()[0].Value; } return ""; } One of my tests look like