在 Compact Framework 中获取文件版本信息
我有一些代码需要能够找到程序集的版本号,给定一个字符串说明它所在的位置。
我无法让它工作:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.