How to use Castle.Windsor in an assembly loaded using reflection

前端 未结 3 2039
Happy的楠姐
Happy的楠姐 2021-01-07 00:26

Let\'s say I have a library Lib.dll, which uses Castle.Windsor to initialize its services.

I have a main application App.exe, which loads Lib.dll on runtime using re

3条回答
  •  礼貌的吻别
    2021-01-07 01:11

    You can try to load the unresolved assemblies within your code by AssemblyResolve event

    AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
    {
         string typeToLoad = args.Name;
         string myPath = new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName;
         return Assembly.LoadFile(...); //or return Assembly.GetExecutingAssembly() etc.
    };
    

提交回复
热议问题