.net-core

How does contravariance work with Func delegate in .net core

心已入冬 提交于 2021-02-05 07:00:52
问题 I have the following piece of code where I am trying to write a generic validation rule for my domain objects. while doing so I have an issue to deal Func delegate supporting variance public class Person { } public class Employee : Person { } internal interface IValidation<T> where T: Person { void AddValidationRule(Func<T,bool> predicateFunction); } internal class BaseValidation : IValidation<Person> { void IValidation<Person>.RegisterValidationRules(Person person) { } } internal class

Why are content files from NuGet packages added as links in .NET Core projects and how can you prevent that?

余生长醉 提交于 2021-02-04 21:48:57
问题 I am developing a .NET Standard library and plan to use it in both .NET Core and .NET Framework projects. My library is dependant on a third library which itself is dependant on a few C binary files. The C binary files have to be copied to the output directory of the project which will be referencing my library. I added the binary files to my library project as content and they are copied to the content and contentFiles directories when the NuGet package is packed with the dotnet pack command

.net core 1.1: Type.GetType from external assembly returns null

谁说我不能喝 提交于 2021-02-04 17:53:16
问题 I'm porting a console app to .NET core which load types from external libraries. In full .NET Framework using Type.GetType("typename, assemblyname") works when the assembly is located in the same folder that executable. In .NET Core, it returns null, wherever I place the library. As a workaround I've installed the System.Runtime.Loader package and attached to Resolving event to force the loading from a full path: AssemblyLoadContext.Default.Resolving += Default_Resolving; type = Type.GetType

404 with static content in Razor Class Library (RCL)

*爱你&永不变心* 提交于 2021-02-04 14:15:23
问题 I am having difficulties implementing static files in razor class library (.net Core 3.1) that are consumed by an ASP.NET Core (v3.1) application. When trying to access the static files, I only get an 404 - Not Found. I followed the following answer on Stackoverflow: https://stackoverflow.com/a/57874357/1099519 or I also cross-checked with the documentation at: https://docs.microsoft.com/en-us/aspnet/core/razor-pages/ui-class?view=aspnetcore-3.0&tabs=visual-studio#create-an-rcl-with-static

System.NotSupportedException when calling OData service from NetCoreApp2.1

邮差的信 提交于 2021-02-04 14:13:16
问题 I have set up a multi targetting (net4.5.2/netstandard2) class library allowing to consume one of our enterprise OData services. To access this OData service we use a proxy class generated with the OData v4 Client Code Generator (v7.5.0) Unfortunately, when trying to use my library in a Netcoreapp2.1 application I encounter an issue as soon as I try to enumerate a collection. Container.MyDataSet.ToList(); produces the following exception : "System.NotSupportedException : This target framework

Best practices on load a form inside a main form, both residing in an external DLL assembly

余生颓废 提交于 2021-01-29 22:50:58
问题 I've loaded an external DLL into your project like this Dim assembly As Assembly = Assembly.LoadFile(libraryPath & "filename.dll") Dim type As Type = assembly.[GetType]("NameSpace.ClassName") // i'm loading as a form here but can be any control Dim frm As Form = TryCast(Activator.CreateInstance(type), Form) What are the best practices if you're loading a class or a control inside the loaded form (above) that resides also inside the same assembly ? for instance: Lets say you loaded an assembly

Best practices on load a form inside a main form, both residing in an external DLL assembly

倖福魔咒の 提交于 2021-01-29 22:41:09
问题 I've loaded an external DLL into your project like this Dim assembly As Assembly = Assembly.LoadFile(libraryPath & "filename.dll") Dim type As Type = assembly.[GetType]("NameSpace.ClassName") // i'm loading as a form here but can be any control Dim frm As Form = TryCast(Activator.CreateInstance(type), Form) What are the best practices if you're loading a class or a control inside the loaded form (above) that resides also inside the same assembly ? for instance: Lets say you loaded an assembly

Multiple routes to the same razor page

穿精又带淫゛_ 提交于 2021-01-29 22:32:58
问题 Background I've got a razor page in my Asp.Net Core 3.1 website called SignupAndApply. It's effectively a copy and paste of the register identity page but: With some additional fields Allows an optional applyid to be passed as part of the route If I pass an applyId as part of the route, I make a couple of label changes to the page and redirect the user somewhere else I want to create two routes for this page: /identity/account/signupandapply/{applyId?} 'when the user is applying and signing

EF Core Analyzer RawSqlStringInjectionDiagnosticAnalyzer error

南笙酒味 提交于 2021-01-29 21:25:03
问题 I am trying to port everything from Entity Framework 6.3 to Entity Framework Core 2.1.2 and this is my first experience with EF Core. I have 2 projects one is my core or infrastructure project with all the entity models, DB Context and repositories and the other one is an asp.Net MVC which is my startup project and using all the services from the core project. Both projects are using .NetStandard Library 2.0.3 and targeted .Net Framework 4.6.2. And I have .Net Core SDK 2.2 on my machine. The

WPF SignalR Server

僤鯓⒐⒋嵵緔 提交于 2021-01-29 19:52:15
问题 I'm really stuck and need some help. I have a .NET Core 3.1 WPF application, which decodes basketball scoreboard data and now I need to send this data over to .html file. The .html file is opened once through CasparCG server as a template and needs to somehow have it's data update real-time. I currently thinking that the best way to do this is to have a SignalR server in the WPF app and a html template running a SignalR client. One of the requirements is that I have to be able to start and