ReflectionOnlyLoad可以收集垃圾吗

ReflectionOnlyLoad可以收集垃圾吗

本文介绍了ReflectionOnlyLoad可以收集垃圾吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想热将一些预先打包的汇编加载到单独的AppDomain中,但是我不知道入门点类的名称甚至是汇编文件。我需要找到这个入口点,所以我可以运行一些初始化例程。



所以我打算做的是在所有文件上运行ReflectionOnlyLoad,并找到跟随一个约定即注释/实现某个界面等。



问题是,如果要从主AppDomain一次又一次地运行ReflectionOnlyLoad,我会开始泄漏内存吗?如果这不能从主应用程序域运行,我的选择是什么,因为我不知道入口点在哪里。



还有关于

解决方案

我推荐 Mono.Cecil 。这是一个简单的程序集,可以使用.net(它不需要Mono运行时)。它提供了一个API来加载程序集作为数据,并且工作得很好。我发现API易于使用,并且在使用反射只加载时遇到的任何问题都没有。



您还可以使用,这是由MS提供一个装配阅读器的开源项目。



另请参见:


I want to "hot" load some pre-packaged assembli(es) into a separate AppDomain, the thing however is I do not know the name of the entry point class or even the assembly file. I need to find this entry point so I can run some initialization routine.

So what I intend to do is to run ReflectionOnlyLoad on all the files and find the one that follows a certain convention ie. annotated/implements a certain interface etc.

Question is, will I start leaking memory if I were to run ReflectionOnlyLoad from the main AppDomain over and over? If this can't be run from the main app domain, what are my options, because again I do not know where the entry point is.

Also any additional information about the subtleties in using ReflectionOnlyLoad is appreciated.

解决方案

I recommend Mono.Cecil. It's a simple assembly you can use on .net (it doesn't require the Mono runtime). It offers an API to load assemblies as data, and works pretty well. I found the API easy to work with, and it suffered from none of the problems I experienced when using reflection-only-load.

You can also use CCI, which is an open source project by MS that offers an assembly reader.

See also: CCI vs. Mono.Cecil -- advantages and disadvantages

这篇关于ReflectionOnlyLoad可以收集垃圾吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 23:19