.net-core

Register Open Generic with dotnet core 3

送分小仙女□ 提交于 2021-01-29 09:21:45
问题 I'm trying to register an Open Generic type in my application but I'm having a strange behavior. The following is working correctly: services.AddTransient(typeof(IA<>), typeof(A<>)); Now, I would like to pass parameters to my A class, because my constructor has some arguments: services.AddTransient(typeof(IA<>), provider => { return ActivatorUtilities.CreateInstance(provider, typeof(A<>), "1", "2"); }); This generates an exception 'Open generic service type 'IA`1[T]' requires registering an

Dotnet restore Docker fail

时间秒杀一切 提交于 2021-01-29 09:05:36
问题 There is problem with Docker and command dotnet restore. I have the docker file: FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base WORKDIR /app EXPOSE 80 EXPOSE 443 FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build WORKDIR /src COPY ["AuthAPI/AuthAPI.csproj", "AuthAPI/"] COPY ["CommonCoreLibrary/CommonCoreLibrary.csproj", "CommonCoreLibrary/"] RUN dotnet restore "AuthAPI/AuthAPI.csproj" COPY . . WORKDIR "/src/AuthAPI" RUN dotnet build "AuthAPI.csproj" -c Release -o

ICollectionView with .net core 3.0

北慕城南 提交于 2021-01-29 08:40:21
问题 I'm migrating my project from classic .net to .net core 3.0. I use in my viewmodel ICollectionView interface and it is not recognized in .net core 3.0 framework. I added several nuget packages to attempt to make it work, but with no luck. Microsoft claims System.ComponentModel defines icollectionview (https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.icollectionview?view=netcore-3.0), but it is not found. I also tried to include windowsbase, but it's not found either. Is my

Consuming NetSuite SOAP Webservice in .Net Core

家住魔仙堡 提交于 2021-01-29 08:26:24
问题 I am having a bit of an issue with integrating with NetSuite API on .Net Core using VS2017 and it has no option to add Web Service. When I consumed their web service using add connected services some objects and classes are missing. In .Net 4.5, the classes and object are available. My manager wants me to write the API in .Net Core. I took the sample code from NetSuite and the very first thing is class NetSuiteService which has important Passport property for login. Anyone had a solution to

.net core docker how to access pfx certificate in code with httpclient? trying to access an external api from container which needs cert

旧街凉风 提交于 2021-01-29 08:14:42
问题 This is how i use it my local machine. I use this pfx cert to fetch data from external API. services.AddHttpClient("test", c =>{}).ConfigurePrimaryHttpMessageHandler(() => { var handler = new HttpClientHandler { ClientCertificateOptions = ClientCertificateOption.Manual, SslProtocols = SslProtocols.Tls12 } handler.ClientCertificates.Add(newX509Certificate2("pathtopfxcert", "pathtokey")); return handler; } But this piece of code throws an error as below when running inside RHEL Container fail:

Is it better to use HttpClient or WebRequest in ASP.NET Core to read the content of a file line by line asynchronously remotely?

吃可爱长大的小学妹 提交于 2021-01-29 08:12:04
问题 I plan to read a remote file line by line asynchronously using https://github.com/Dasync/AsyncEnumerable (since there is not yet Async Streams [C# 8 maybe]: https://github.com/dotnet/csharplang/blob/master/proposals/async-streams.md): public static class StringExtensions { public static AsyncEnumerable<string> ReadLinesAsyncViaHttpClient(this string uri) { return new AsyncEnumerable<string>(async yield => { using (var httpClient = new HttpClient()) { using (var responseStream = await

How to parse XML in Powershell with Select-Xml and Xpath?

筅森魡賤 提交于 2021-01-29 08:10:38
问题 obvious output for this example would be the date and time. In the context of iterating over an xml document, how is this document correctly cast or converted to xml in Powershell dotnet core on Linux ? PS /home/nicholas/flwor> PS /home/nicholas/flwor> Select-Xml -Xml (Get-Date | ConvertTo-Xml) -XPath "/Objects/Object" Node Path Pattern ---- ---- ------- Object InputStream /Objects/Object PS /home/nicholas/flwor> PS /home/nicholas/flwor> (Get-Date | ConvertTo-Xml).OuterXml <?xml version="1.0"

Project targets unsupported platform

喜你入骨 提交于 2021-01-29 07:27:36
问题 I have a Visual Studio solution with several projects in it. I am trying to get the core project to build and I am getting the following error: "The project targets or references an unsupported platform: .NETPlatform,Version=v5.0. Applied.Hosted.Core" I did some googling and found a result that made me believe that I need to add the following to the project.json file. "frameworks": { "dnxcore50": { } } My project does not have a project.json file. This is some work that I have taken over from

.Net Core 3.1 SPA React Application doesn't serve Hangfire dashboard / Swagger on production

╄→гoц情女王★ 提交于 2021-01-29 07:22:50
问题 After installing the React app template from .NET Core 3.1 using dotnet new react the application works perfectly in Development and Production. The problem appears when trying to use Swagger or Hangfire dashboard endpoints. After the app is created I add the package reference for Hangfire and for practical purposes the memory storage: <PackageReference Include="Hangfire" Version="1.7.*" /> <PackageReference Include="Hangfire.MemoryStorage" Version="1.7.0" /> In Startup.cs : public void

Dotnet core identityserver4 reverse proxy

守給你的承諾、 提交于 2021-01-29 07:15:49
问题 Hi everybody I have a problem with my reverse proxy configuration for my dotnet core application. My problem is that when I am using identityserver discovery endpoint the port number is missing from the end of my url. I have a request for the discorvery document to https://:8421/.well-known/openid-configuration and the response is the following and the problem here is that the clients of the authentication service are using the document as a base for verification, using jwks_uri property from