开发者

what assembly loading mechanism suit my case

  • I have httphandler that in its constructor i need to load an assembly, where this ass开发者_开发技巧embly need to be replaceable without the need to restart the application.
  • this assembly, include utility-like classes where all the classes have only static methods.
  • after loading the assembly, i traverse all its classes methods and store a delegate for each method in a dictionary as follows:

    MyDictionary.Add("SomeMethodName",
        (MyDelegate)Delegate.CreateDelegate(typeof(MyDelegate),
            MyAssembly.GetType("MyNamespace.MyClass").GetMethod("SomeMethod"))
    
  • now what will be the best assembly loading technique in my case as am only using stateless classes? i have googled this where all subject are about to create a separate appdomain and load the assemblies there, does this suit my case?


.NET doesn't allow unloading assemblies. The only way to do so is unloading of AppDomain. So you either should create new AppDomain and load your assembly there (and use marshaling between app domains, instead of just loading and traversing it) or just adding assemblies without unloading them.

Take a look here to see how loading in the non-default AppDomain works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜