I am trying to get my component to be resolved in my Web API project. I am using this code snippet for registering which works fine in my UnitTest project.
Program.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:
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:
<?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. 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.
Can anyone shed some light on what I am missing, please?