如何删除应用于类属性的程序集?

我有一个类具有public Assembly LoadedAssembly { set; get; } public Assembly LoadedAssembly { set; get; }

 var assemblyName = AssemblyName.GetAssemblyName(fullPathToDLLFile); myClass.LoadedAssembly = Assembly.Load(assemblyName); 

这个类我保留在Application.Current.Properties["MyClass"]

我尝试将它Application.Current.Properties["MyClass"] = null; ,就像Application.Current.Properties["MyClass"] = null; 但它没有帮助。

我看到加载的程序集工作(它内部有一个计时器,它正在工作)。

我该如何清洁它?

(我不使用AppDomain d = AppDomain.CreateDomain("NewDomain", null, domaininfo);加载程序集。)

您不能随意卸载程序集,而必须卸载加载程序集的AppDomain(卸载AppDomain中的所有程序集)。 如果您没有将其加载到单独的AppDomain中,那么唯一的方法就是关闭应用程序。

此问题中有各种链接,其中包含不支持此操作的详细信息: 如何从主AppDomain卸载程序集?

您无法卸载程序集,但可以卸载加载程序集的AppDomain。 看到这个解释。