C#获取非托管的DLL版本 [英] C# getting version of unmanaged dll
问题描述
我打电话是从我管理的C#代码的非托管的dll,想检查我打电话正确的版本。
I'm calling an unmanaged dll from my managed c# code and wanted to check I'm calling the right version.
我试图加载程序集(以再获取资源文件,然后获取版本)的代码是:
cur_version = Assembly.LoadFile( X:\Workspace\yreceipts_pos\yRprintProcessor\Debug\yRprintProcessor.dll);
它的失败,因为这个错误的:
该模块应包含一个程序集清单。 (异常来自HRESULT:0x80131018)
The code I'm trying to load the assembly (to then get the resource file and then get the version) is:
cur_version = Assembly.LoadFile("X:\Workspace\yreceipts_pos\yRprintProcessor\Debug\yRprintProcessor.dll");
It's failing because of this error:
The module was expected to contain an assembly manifest. (Exception from HRESULT: 0x80131018)
有谁知道如何解决这个问题,或有更好的方法来检查非托管DLL的版本从托管的C#代码?
Does anyone know how to get around this or have a better way to check the version of an unmanaged dll from managed c# code?
在提前,
理查德
Thanks in advance, Richard
推荐答案
作为感谢通过logicnp陈述;的的Assembly.Load仅用于管理组件。要确定您可以使用System.Diagnostics.FileVersionInfo.GetVersionInfo(文件名)和加载并调用DLL中您可以参考这些文章非托管程序任何版本-ED文件的版本:
As stated by logicnp; the Assembly.Load is for managed assemblies only. To determine the version of any version-ed file you can use System.Diagnostics.FileVersionInfo.GetVersionInfo(filename) and to load and call unmanaged procedures in DLLs you can refer to these articles:
http://blogs.msdn.com/jonathanswift/archive/2006/ 10月2日/ 780637.aspx
http://blogs.msdn.com/jonathanswift/archive/2006/10/03/Dynamically-calling-an-unmanaged-dll-from-.NET- _2800_C_23002900_.aspx
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版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!