SAP HANA的ADO.NET Provider-版本不匹配问题 [英] ADO.NET Provider for SAP HANA - Version mismatch issue

查看:145
本文介绍了SAP HANA的ADO.NET Provider-版本不匹配问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF应用程序,该应用程序在本地开发环境中将ADO.NET客户端用于SAP HANA(版本1.0.9.0),并且在我的SAP.DATA.HANA.v4.5.dll中添加了相同的引用。码。连接正常。

I have a WPF application which is using ADO.NET client for SAP HANA ( Version 1.0.9.0) in my local development environment and i have added the same reference of SAP.DATA.HANA.v4.5.dll in my code. The connection works fine.

当我尝试在具有不同版本的ADO.NET客户端的服务器上运行同一应用程序时,会引发错误。
应该从位置(C:\Program Files\sap\hdbclient\ado.net\v4.5)引用客户端,而不是版本号?

When i try to run the same application on a server which is having a different version of ADO.NET client , it throws error. It should refer to the client from the location(C:\Program Files\sap\hdbclient\ado.net\v4.5) instead of version number ?

有人可以解释我是否做错了事。

Can someone please explain if i am doing something wrong.

推荐答案

您没有做错任何事情。但是我认为您缺少有关装配引用的关键知识。

You're not doing anything wrong. But I think you're missing a key piece of knowledge about assembly references. And there are ways to deal with it, both for you and SAP.

.NET引用程序集时,它会针对编译时使用的确切版本进行处理。这意味着,如果在运行时版本号不同,则默认情况下它将失败。用于强名称程序集或区域性的签名密钥上的差异也会导致程序集加载失败。此先前的答案对此进行了讨论并提出了一种解决方案使用 AssemblyResolve 事件处理它。如果您的应用程序具有复杂的插件加载机制,那么您可能还有很多工作要做,但是如果它确实很简单,则可以轻松进行更新。当然,如果客户端数据库进行了重大更改,您仍然会遇到问题,但是它们将是不同的问题。

When .NET references an assembly, it does so against the exact version used at compile time. Which means if at runtime the version number is different, it fails by default. Differences in the signing key used for strong-named assemblies or cultures can also cause the assembly loading to fail. This previous answer discusses that and suggests an approach to dealing with it using the AssemblyResolve event. You might have a lot more to do if your application has a complex plugin loading mechanism, but if it's really simple, you can get it updated with minimal effort. Of course, you'll still have issues if the client DB makes a breaking change, but they'll be different issues.

另一种方法是编辑应用程序的配置文件重定向程序集版本。有时甚至将Nuget软件包设置为自动将这些重定向插入到应用程序配置文件中。不幸的是,考虑到版本的更改频率,HANA并不是一个容易的策略。您需要知道提供的确切版本。因此,如果将应用程序部署到具有不同HANA版本的多个客户端上,可能会有些噩梦。

Another approach is to edit your application's configuration file to redirect assembly versions yourself. Sometimes Nuget packages are even set up to automatically insert these redirects into the application configuration file. Unfortunately this isn't an easy strategy with HANA given how frequently the versions change. And you need to know the exact version that's present to do this. So if you're deploying your application to multiple clients with different HANA versions, it could be a bit of a nightmare.

可悲的是,已经有一种现有的机制由发布库的供应商来处理此类事情。它称为发布者策略组装,但是SAP通过包括(并嵌入)有史以来最无用的绑定重定向来破坏了策略组装的交付。

The sad thing is that there's already an existing mechanism in place for dealing with this sort of thing by the vendor who publishes the library. It's called a publisher policy assembly, but SAP botched its delivery of the policy assembly by including (and embedding) the most useless binding redirect ever conceived.

通常,使用绑定重定向,目的是允许您的程序集无缝升级到较新版本,只要您的类型没有显着更改其公共接口即可。您要做的就是在XML中指定此版本可以处理的版本范围。

Normally, with a binding redirect, the purpose is to allow for seamless upgrading of an assembly to a newer version as long as your types haven't changed their public interfaces significantly. All you do is specify the range of versions that can be handled by this version in the XML.

SAP,但是将其作为绑定重定向元素:

SAP, however has this as their binding redirect element:

<bindingRedirect oldVersion="1.0.120.0-1.0.120.0" newVersion="1.0.120.0" />

您仅允许当前安装的版本他们的数据库客户端(在本例中为 1.0.120.0 )。而且,对于这种严格的版本控制,该DLL的ADO.NET类的更改不足。就我而言,关于不同程序集版本的所有内容都是完全相同的。

Which does you the wonderful favor of allowing only the currently installed version of their DB client (in this case, 1.0.120.0). And no, that DLL doesn't change its ADO.NET classes enough for this sort of strict versioning. In my case, everything about the different assembly versions was exactly the same.

如果我能够与HANA团队中有理智的人保持联系,并且有足够的影响力进行修复,为此,我建议他们将 oldVersion 属性正确设置为最早的可升级版本,并升级每个后续驱动程序包。因此,如果您已安装 1.0.120.0 ,则使用:

Had I the ability to get in touch with someone sane on the HANA team with enough clout to fix this, I'd suggest they set the oldVersion attribute properly to the oldest upgradable version and upgrade every subsequent driver package. So if you've installed 1.0.120.0, it'd look something more like this with the :

<bindingRedirect oldVersion="1.0.9.0-1.0.120.0" newVersion="1.0.120.0" />

然后,计算机上的任何软件都可以使用它,而无需付出额外的努力。我的意思是,它在GAC中。他们可以很轻松地简化此工作。尽管他们需要修补所有版本的HANA客户端,但许多应用程序(甚至是SAP随附的应用程序)都与特定的HANA版本绑定。如果他们只是将其修复为最新版本,那么几年后我们将看不到任何好处。

And then it could be used by any software on the machine without extra effort. I mean, it's in the GAC. It wouldn't be that much effort for them to make this significantly easier. Although they'd need to patch all versions of the HANA client, as many applications (even those shipped by SAP) are tied to specific HANA versions. If they only fixed it in the latest version, we wouldn't see the benefits for several years.

这篇关于SAP HANA的ADO.NET Provider-版本不匹配问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆