- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试使用以下代码在 C# 中获取 exe 的汇编版本
Assembly asm = Assembly.LoadFrom(address);
return asm.GetName().Version;
它运行完美,但如果我在使用此功能后尝试删除 exe,它会显示“拒绝访问”,因为该 exe 正被另一个进程使用!
是否有任何 Dispose 调用或释放文件句柄的东西或任何其他解决方案?
最佳答案
除了卸载应用程序域之外,没有其他方法可以卸载程序集。参见 How to: Load and Unload Assemblies :
There is no way to unload an individual assembly without unloading all of the application domains that contain it. Use the Unload method from AppDomain to unload the application domains. For more information, see Unloading an Application Domain.
如果您只想获取文件的版本,请尝试使用 FileVersionInfo.GetVersionInfo .
关于c# - 释放 Assembly.LoadFrom 文件句柄,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3281221/
我正在加载 Assembly.LoadFrom存储在应用程序基本路径之外的程序集 (A);我加载的程序集引用了同一目录中的另一个 .net 程序集 (B)。 当我尝试使用 A 程序集的某些方法时,Fu
我正在使用 Assembly.LoadFrom 加载我的 dll 并稍后创建它的实例。 这是我的问题。 有时我可以修改我的 dll。更准确地说,我删除它并创建一个具有相同名称和路径的新文件。当我再次实
我一直在尝试使用 Assembly.LoadFrom() 设置插件系统,该插件系统动态加载 .exe 目录的子文件夹中的 dll。 我有一个接口(interface)库被 .exe 和插件引用。构建完
我对 Assembly.LoadFrom 的行为感到困惑.在我的应用程序中,我将 Assembly.LoadFrom 调用到 .NET .exe 并使用 EntryPoint.Invoke 启动它(这
我正在使用加载另一个程序集 Assembly.LoadFrom("path.exe"); 然后我似乎无法从文件系统中删除该 exe。所以我想知道这条路径是否保留一个打开的文件句柄以及我如何关闭它? 最
是否可以使用带有 Evidence 参数的 Assembly.LoadFrom 重载来确保程序集是强命名的?我希望能够指定程序集名称、区域性、版本和公钥 token 。如果任何此信息不匹配,程序集将无
public Assembly LoadAssembly(string assemblyName) //@"D://MyAssembly.dll" { m_assembly = Assembl
我正在尝试根据 Environment.Is64BitProcess 实现某些程序集的动态加载。 这基本上是这样工作的: 为 AppDomain.AssemblyResolve event 注册一个事
我在一个给定的解决方案中有多个项目。从 ProjectA 我将“myProjectB.dll”作为程序集名称传递给方法调用在项目C中。 当我在 ProjectC 中执行以下命令时,程序集名称是“myP
我有几个资源 DLL,当应用程序开始使用以下代码时,我当前会加载它们: Assembly ass = Assembly.LoadFrom(fi.FullName);Type t = ass.GetTy
想象一下这个场景: var ass1 = Assembly.LoadFrom(@"C:\Work\3.59\assembly1.dll"); var ass2 = Assembly.LoadFrom(
我正在尝试使用以下代码在 C# 中获取 exe 的汇编版本 Assembly asm = Assembly.LoadFrom(address); return asm.GetName().Versio
在这里引用 Jon Skeet 的回答:Pass An Instantiated System.Type as a Type Parameter for a Generic Class 我需要根据泛型
我有一个 WPF 程序集,我使用 LoadFrom 加载上下文从 native 代码在互操作场景中使用,如下所示: AppDomain.CreateInstanceFrom("c:\mydlls\my
我需要检查加载 dll 后运行 GetTypes() 的时间量。代码如下。 Assembly assem = Assembly.LoadFrom(file); sw = Stopwatch.Start
GetCustomAttribute 找不到通过自定义 AssemblyLoadContext 中的“Assembly.LoadFrom(path)”加载的程序集的属性。 负载流: 主应用有自定义的
我正在开发一个小型演示,从 DLL 文件组装类。 这是我的代码: string path = @"\\192.168.1.3\shareFolder\testzwm.dll"; Assembly as
我正在开发一个从 DLL 文件组装类的小演示。 这是我的代码: string path = @"\\192.168.1.3\shareFolder\testzwm.dll"; Assembly ass
我正在制作一个音频应用程序,它使用使用加载的 dll 插件Assembly.LoadFrom(file).GetTypes()... 和 Activator.CreateInstance(T)。 我的
我正在使用 Assembly.LoadFrom(fileName) 加载程序集。当 fileName 在本地机器上时,一切正常。但是,当相同的文件(和依赖项)位于远程网络共享上时,当我尝试从创建新的
我是一名优秀的程序员,十分优秀!