Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use <install directory=""> from XML file to register a class. #637

Open
OIIvIIO opened this issue Oct 11, 2022 · 1 comment
Open

Comments

@OIIvIIO
Copy link

OIIvIIO commented Oct 11, 2022

Hi,

I want to load a DLL from different paths from executing directory and resolve from this DLL. But Castle.Windsor throw this exception

Castle.MicroKernel.SubSystems.Conversion.ConverterException: 'Could not convert string 'EngineA.AClass, EngineA' to a type. Assembly EngineA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null was matched, but it doesn't contain the type. Make sure that the type name was not mistyped.'
   at Castle.MicroKernel.SubSystems.Conversion.TypeNameConverter.GetType(String name) in C:\Users\name\Source\Repos\Windsor\src\Castle.Windsor\MicroKernel\SubSystems\Conversion\TypeNameConverter.cs:line 125
   at Castle.MicroKernel.SubSystems.Conversion.TypeNameConverter.PerformConversion(String value, Type targetType) in C:\Users\name\Source\Repos\Windsor\src\Castle.Windsor\MicroKernel\SubSystems\Conversion\TypeNameConverter.cs:line 72
   at Castle.MicroKernel.SubSystems.Conversion.DefaultConversionManager.PerformConversion(String value, Type targetType) in C:\Users\name\Source\Repos\Windsor\src\Castle.Windsor\MicroKernel\SubSystems\Conversion\DefaultConversionManager.cs:line 106
   at Castle.MicroKernel.SubSystems.Conversion.DefaultConversionManager.PerformConversion[TTarget](String value) in C:\Users\name\Source\Repos\Windsor\src\Castle.Windsor\MicroKernel\SubSystems\Conversion\DefaultConversionManager.cs:line 134
   at Castle.Windsor.Installer.DefaultComponentInstaller.GetType(IConversionManager converter, String typeName) in C:\Users\name\Source\Repos\Windsor\src\Castle.Windsor\Windsor\Installer\DefaultComponentInstaller.cs:line 228
   at Castle.Windsor.Installer.DefaultComponentInstaller.SetUpComponents(IConfiguration[] configurations, IWindsorContainer container, IConversionManager converter) in C:\Users\name\Source\Repos\Windsor\src\Castle.Windsor\Windsor\Installer\DefaultComponentInstaller.cs:line 183
   at Castle.Windsor.Installer.DefaultComponentInstaller.SetUp(IWindsorContainer container, IConfigurationStore store) in C:\Users\name\Source\Repos\Windsor\src\Castle.Windsor\Windsor\Installer\DefaultComponentInstaller.cs:line 50
   at Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] installers, DefaultComponentInstaller scope) in C:\Users\name\Source\Repos\Windsor\src\Castle.Windsor\Windsor\WindsorContainer.cs:line 323
   at Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] installers) in C:\Users\name\Source\Repos\Windsor\src\Castle.Windsor\Windsor\WindsorContainer.cs:line 453
   at Reflection.Program.Main(String[] args) in C:\Users\name\Source\Repos\Reflection\Reflection\Program.cs:line 26

It is XML config file:

CastleInstallerConfig.xml
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
	  <installers>
		  <install directory="C:\Users\name\Source\Repos\Reflection\EngineA\bin\Release" maskMask="EngineA.dll"></install>
	  </installers>
	  <components>
		      <component id="AClass" service="Reflection.IClass, Reflection" type="EngineA.AClass, EngineA" lifestyle="transient" ></component>
	  </components>
</configuration>

It's main method

public static void Main(string[] args)
{
            IWindsorContainer container = new WindsorContainer();
            //container.Install(FromAssembly.InDirectory(new AssemblyFilter("C:\\Users\\name\\Source\\Repos\\Reflection\\EngineA\\bin\\Release"))); // dll in this directory
            container.Install(Configuration.FromXmlFile("C:\\Users\\name\\Source\\Repos\\Reflection\\Reflection\\CastleInstallerConfig.xml")); // xml path. throw exception from this
            IClass aa = container.Resolve<IClass>();
            string res = aa.DoSomethings();
            Console.WriteLine(res);
}

Class and interface are as follows:

// It's in the EngineA.dll
namespace EngineA
{
    public class AClass: IClass
    {
        public string DoSomethings()
        {
            return "FromEngineA";
        }

    }
}
It's in Reflection.exe
namespace Reflection
{
    public interface IClass
    {
        string DoSomethings();
    }
}

When I moved Engine.dll to the same folder as Reflection.exe , it can be work and not throw exception.

@AndreyPolovodov
Copy link

I can't do dynamic loading via config file even in same directory - #647

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants