简体   繁体   English

Windsor 解决问题 - ASP.NET Core Web API.Net version 6 cannot register my.Net framework 4.8 C# Library assembly

[英]Windsor resolve issue - ASP.NET Core Web API .Net version 6 cannot register my .Net framework 4.8 C# Library assembly

I am trying to get my component to be resolved in my Web API project.我试图让我的组件在我的 Web API 项目中得到解决。 I am using this code snippet for registering which works fine in my UnitTest project.我正在使用此代码片段进行注册,这在我的 UnitTest 项目中运行良好。

Program.cs程序.cs

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
IWindsorContainer container = new WindsorContainer(new XmlInterpreter("Windsor.config"));
container.Resolve<IDataProvider>();

But in my.Net Core Web API project I get this error:但是在 my.Net Core Web API 项目中我得到了这个错误:

Castle.MicroKernel.SubSystems.Conversion.ConverterException
  HResult=0x80131500
  Message=Could not convert string 'MyProject.DataAccess.DataProviders.PDataProvider, MyProject.DataAccess, Version=1.0.0.0, Culture=neutral' to a type. Assembly was not found. Make sure it was deployed and the name was not mistyped.
  Source=Castle.Windsor
  StackTrace:
   at Castle.MicroKernel.SubSystems.Conversion.TypeNameConverter.GetType(String name)
   at Castle.MicroKernel.SubSystems.Conversion.TypeNameConverter.PerformConversion(String value, Type targetType)
   at Castle.MicroKernel.SubSystems.Conversion.DefaultConversionManager.PerformConversion(String value, Type targetType)
   at Castle.MicroKernel.SubSystems.Conversion.DefaultConversionManager.PerformConversion[TTarget](String value)
   at Castle.Windsor.Installer.DefaultComponentInstaller.SetUpComponents(IConfiguration[] configurations, IWindsorContainer container, IConversionManager converter)
   at Castle.Windsor.Installer.DefaultComponentInstaller.SetUp(IWindsorContainer container, IConfigurationStore store)
   at Program.<Main>$(String[] args) in C:\source\repos\F2\MyProject.F2\Program.cs:line 8

My Windsor.config file:我的 Windsor.config 文件:

<?xml version="1.0" encoding="utf-8" ?>
<castle>
    <components>
        <component id="DataProvider" 
                   service="MyProject.Interfaces.DataProviders.IDataProvider, MyProject.Interfaces" 
                   type="MyProject.DataAccess.DataProviders.PDataProvider, MyProject.DataAccess, Version=1.0.0.0, Culture=neutral"></component>
    </components>
</castle>

My 'MyProject.DataAccess.dll' is in the '/bin' folder for both debug and release, which I am copying manually.我的“MyProject.DataAccess.dll”位于用于调试和发布的“/bin”文件夹中,我正在手动复制它。 Either the 'MyProject.DataAccess.dll' should be copied elsewhere where the Web API app can 'see' or locate it or the version of 'MyProject.DataAccess.dll' (.Net framework 4.8) is a problem.应将“MyProject.DataAccess.dll”复制到 Web API 应用程序可以“查看”或找到它的其他位置,或者“MyProject.DataAccess.dll”(.Net framework 4.8)的版本有问题。

Can anyone shed some light on what I am missing, please?任何人都可以阐明我所缺少的东西吗?

Use .NET Standard TFM instead of.NET Framework.使用.NET 标准TFM 而不是 .NET Framework。 This way the assembly would be compatible between runtimes.这样程序集将在运行时之间兼容。

I was under the impression that .net core was backward compatible我的印象是 .net 内核向后兼容

The main idea behind Net Core is to allow moving forward and breaking back-compat. Net Core 背后的主要思想是允许向前移动和向后兼容。 They (Core team) somewhat trying to be source-level compatible to easier mitigation from.NETFx, but it's not a goal in the long term run.他们(核心团队)在某种程度上试图实现源代码级兼容,以便更容易地从 .NETFx 中缓解,但这不是长期目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何解决 ASP.NET Core Web API 项目中类库的 Windsor 容器依赖项? - How to resolve Windsor container dependencies for a class library in ASP.NET Core Web API project? 调试 ASP.NET (.NET Framework 4.8) web 应用程序时,没有为新 csproj 格式的 (.NET Framework 4.8) 库加载符号 - No symbols loaded for a (.NET Framework 4.8) library in new csproj format when debugging a ASP.NET (.NET Framework 4.8) web application 使用 C# ASP.NET Core Web API 进行谷歌身份验证 - Google authentication with C# ASP.NET Core Web API C# ASP.NET Core Web API 包含与 where - C# ASP.NET Core Web API include with where 将ASP.Net Core 2(.NET Framework)Web Api拆分为类库和托管项目是否可行/明智? - Is it possible/sensible to split ASP.Net Core 2 (.NET Framework) Web Api into Class Library and Hosting projects? C# HttpClient cannot send authorization header to ASP.NET Core Web API - C# HttpClient cannot send authorization header to ASP.NET Core Web API ASP.NET 核心 Web API 使用实体框架核心 - ASP.NET Core Web API using Entity Framework Core ASP.NET Core Web API - 如何在依赖约束之外解析检测到的包版本 - ASP.NET Core Web API - How to resolve Detected package version outside of dependency constraint c# asp.net core 注册嵌套泛型类 - c# asp.net core register nested generic class .NET Core和.NET Framework的C#库 - C# library for .NET Core and .NET Framework
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM