将.dll文件添加到程序集(ApplicationParts.Add),并将其删除(ApplicationParts.RemoveAt)后,是否可以删除它?
var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(pathToWrite + fileModel.Name + ".dll");
if (assembly != null)
{
_partManager.ApplicationParts.Add(new AssemblyPart(assembly));
CustomActionDescriptorChangeProvider.Instance.HasChanged = true;
CustomActionDescriptorChangeProvider.Instance.TokenSource.Cancel();
}
_partManager.ApplicationParts.RemoveAt(3);
File.Delete(pathToWrite + fileModel.Name + ".dll");// error