汇编版本加载问题和SQL CE
我有一个利用 SQL CE 3.5 和 .NET 3.5 的实体框架的应用程序。
我们遇到了 SQL CE 3.5 SP2 RTM 的一个已知问题,该问题会导致应用程序崩溃。因此,我们获得了累积更新 2,它显然解决了该问题。
由于我们通过 XCopy 使用应用程序部署了 SQL CE,因此我们假设只需用 CU2 版本替换本地托管和非托管 DLL 就可以解决问题。
如果 SQL CE 已提前安装在计算机上(因此位于 GAC 中),我们的应用程序将忽略程序集和 DLL 的较新版本,并从 GAC 加载旧的、损坏的版本。
我们确定卸载 SQL CE(从而将其从 GAC 中删除)或更新 GAC 的程序集允许我们的应用程序使用正确的版本。
有更好的办法吗?我尝试过 Assembly.LoadFile,但这似乎不起作用。 (两个版本都已加载,但较旧的版本是实际使用的版本。)
I have an application that utilizes SQL CE 3.5 and the Entity Framework from .NET 3.5.
We encountered a known issue with SQL CE 3.5 SP2 RTM that causes application crashes. As a result, we obtained Cummulative Update 2 which apparently addresses the issue.
Since we deployed SQL CE via XCopy with our application, we assumed that simply replacing the local managed and unmanaged DLLs with the CU2 versions would do the trick.
In the case where SQL CE has been installed on the machine ahead of time (and is therefore in the GAC), our application ignores the newer versions of the assemblies and DLLs and loads the old, broken versions from the GAC.
We determined that that uninstalling SQL CE (and therefore removing it from the GAC) or updating the GAC's assemblies allows our application to use the correct version.
Is there a better way? I've tried Assembly.LoadFile, but that didn't seem to work. (Both versions were loaded, but the older one was the one that was actually in use.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的目标是特定版本的 SQL CE 程序集吗?在属性选项卡中,检查引用的特定版本属性是否设置为True。另请检查您是否没有程序集绑定重定向来指示 .Net 框架使用旧程序集。
我只能假设累积更新 2 增加了版本号,如果是这种情况,则仅当程序集版本完全匹配时才应使用 GAC 中的程序集。如果它们不匹配,则 .Net 框架应该使用应用程序目录中找到的程序集,因为它们与版本号完全匹配。
Are you targeting a specific version of the SQL CE assemblies? In the properties tab check that the Specific Version property of the reference is set to True. Also check that you don't have an assembly binding redirect that directs the .Net framework to use the older assemblies.
I can only assume that the Cummulative Update 2 incremented the version number, and if this is the case the assemblies in the GAC should only be used if the assembly version matches exactly. If they don't match then the .Net framework should use the assemblies found in your application directory, as they do match the version number exactly.