在 Compact Framework 中获取文件版本信息

发布于 2024-09-25 09:22:03 字数 587 浏览 1 评论 0原文

我有一些代码需要能够找到程序集的版本号,给定一个字符串说明它所在的位置。

我无法让它工作:

Assembly assembly = Assembly.LoadFrom("\\Program Files\\Microsoft SQL Server Compact Edition\\v3.5\\sqlcecompact35.dll");

抛出 System.IO.IOException:未找到文件或程序集名称 '\Program Files\Microsoft SQL Server Compact Edition\v3.5\sqlcecompact35.dll' 或其依赖项之一。

但该文件确实存在:

FileInfo fileInfo = new FileInfo("\\Program Files\\Microsoft SQL Server Compact Edition\\v3.5\\sqlcecompact35.dll"); 

创建一个对象,其中 fileInfo.Exists == true。

我应该传递不同的文件名/路径来加载 SQL CE 程序集吗?谢谢。

I have some code that needs to be able to find the version number of an assembly, given a string saying where it's located.

I can't get this to work:

Assembly assembly = Assembly.LoadFrom("\\Program Files\\Microsoft SQL Server Compact Edition\\v3.5\\sqlcecompact35.dll");

throws a System.IO.IOException: File or assembly name '\Program Files\Microsoft SQL Server Compact Edition\v3.5\sqlcecompact35.dll', or one of its dependencies, was not found.

Yet the file does exist:

FileInfo fileInfo = new FileInfo("\\Program Files\\Microsoft SQL Server Compact Edition\\v3.5\\sqlcecompact35.dll"); 

creates an object where fileInfo.Exists == true.

Should I be passing in a different filename/path to load the SQL CE assembly? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

永不分离 2024-10-02 09:22:03

sqlcecompact35.dll 不是托管程序集,因此无法通过反射加载。该 DLL 以及其他文件,如 sqlceqp35.dll、sqlceca35.dll(在发行版中查找所有文件)是数据引擎的核心部分。您可以通过这种方式加载的唯一托管程序集是 System.Data.SqlServerCe.dll。

编辑

在 Compact Framework 中获取本机文件的文件版本信息并不那么容易。我已经构建并 博客为您检索此信息的解决方案

sqlcecompact35.dll is not a managed assembly and therefore cannot be loaded via Reflection. That DLL, along with other files like sqlceqp35.dll, sqlceca35.dll (look in the distribution for all files) are the natie pieces of the data engine. The only managed assembly that you might load this way is System.Data.SqlServerCe.dll.

EDIT

Getting the file version info for a native file is not near as easy in the Compact Framework. I've built and blogged a solution to retrieve this info for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文