gpt4 book ai didi

C# 获取非托管 dll 的版本

转载 作者:行者123 更新时间:2023-11-30 19:13:50 27 4
gpt4 key购买 nike

我正在从我的托管 C# 代码中调用非托管 dll,并想检查我是否调用了正确的版本。

我试图加载程序集(然后获取资源文件然后获取版本)的代码是: cur_version = Assembly.LoadFile("X:\Workspace\yreceipts_pos\yRprintProcessor\Debug\yRprintProcessor.dll");由于此错误,它失败了:模块应该包含程序集 list 。 (HRESULT 异常:0x80131018)

有谁知道如何解决这个问题或有更好的方法从托管 C# 代码检查非托管 dll 的版本?

提前致谢,理查德

最佳答案

如 logicnp 所述; Assembly.Load 仅适用于托管程序集。要确定任何版本化文件的版本,您可以使用 System.Diagnostics.FileVersionInfo.GetVersionInfo(filename) 并加载和调用 DLL 中的非托管过程,您可以引用这些文章:

http://blogs.msdn.com/jonathanswift/archive/2006/10/02/780637.aspx http://blogs.msdn.com/jonathanswift/archive/2006/10/03/Dynamically-calling-an-unmanaged-dll-from-.NET-_2800_C_23002900_.aspx

祝你好运......

关于C# 获取非托管 dll 的版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2459786/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com