与Oracle DataAccess有关:“动态程序集不支持被调用的成员." [英] Oracle DataAccess related: "The invoked member is not supported in a dynamic assembly."

查看:434
本文介绍了与Oracle DataAccess有关:“动态程序集不支持被调用的成员."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道此类错误已在SO上多次讨论.有些人发现这是DLL文件中的错误,有些人通过更改DLL版本来解决,另一些似乎没有任何线索.无论如何,我只是发贴试试运气:

在C#GUI的网格中选择一行时,我的应用程序崩溃了. stackTrace看起来像:

System.NotSupportedException: The invoked member is not supported in a dynamic assembly.
at Oracle.DataAccess.Types.OracleUdt.GetAllReferencedAssemblies()
at Oracle.DataAccess.Client.RegAndConfigRdr.setudtmapping(Hashtable& s_mapUdtNameToMappingObj)
at System.Reflection.Emit.InternalAssemblyBuilder.get_Location()
at Oracle.DataAccess.Types.OracleUdt.SetCustomTypeMappings()
at Oracle.DataAccess.Types.OracleUdt.GetUdtName(String customTypeName, String dataSource)
at Oracle.DataAccess.Client.OracleParameter.SetUDTFromCustomObject(OracleConnection conn, IOracleCustomType customObj, Int32 i)
at Oracle.DataAccess.Client.OracleParameter.PreBind_OracleObject(OracleConnection conn)
at Oracle.DataAccess.Client.OracleParameter.PreBind_Object(OracleConnection conn)
at Oracle.DataAccess.Client.OracleParameter.PreBind(OracleConnection conn, IntPtr errCtx, Int32 arraySize)
at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)
at Oracle.DataAccess.Client.OracleCommand.ExecuteReader()

我的同事没有遇到此问题,所以我认为这与我的本地计算机有关.

我在GAC中查找了Oracle.DataAccess.dll,看起来像(我使用.Net 4.0,位于c:/windows/Microsoft.NET/assembly下):

find . -name "Oracle.*DataAccess*.dll"
./GAC_32/Oracle.DataAccess/v4.0_4.121.2.0__89b483f429c47342/Oracle.DataAccess.dll
./GAC_MSIL/Oracle.ManagedDataAccess/v4.0_4.121.2.0__89b483f429c47342/Oracle.ManagedDataAccess.dll

我的同事使用了:V2.121.3.0,没有托管的dll.我的DLL与他们的DLL之所以不同的原因是我使用VS2015与VS2013,而我花了一段时间才弄清楚了(至少到那时)正确的Oracle DLL,这些DLL可以使应用程序在VS2015下构建和运行. /p>

最近的帖子在这里:通过Oracle UDT存储过程引发对ExecuteNonQuery的错误,但没有解决方案.

解决方案

以防万一仍然有人遇到此问题.当我尝试将Oracle Driver从11. *升级到12. *时,我也发生了同样的事情.

我发现在运行时,它会从GAC加载2.12 *和4.12 * Oracle.DataAccess程序集.

快速的解决方案是简单地将运行时程序集重定向到4.12 *,因为我们的应用程序目标是.Net Framework 4. *. 我的首选解决方案是迁移到使用Managed Oracle Driver NuGet版本.

即使他们在dll中检查了(!assembly.IsDynamic),如@ AardVark71所述,我仍然不知道为什么会引发异常.但是该行"assembly.Location"是在12. * Oracle Driver中引入的.也不太确定为什么要加载两个版本的Oracle.DataAccess Assembly

I understand that such an error has been discussed multiple times on SO. Some turned that was a bug in DLL file, some resolved by changing DLL version, other didn't seem to have a clue. Anyway I just post to try my luck:

My application crashed when selecting a row in a grid on a C# GUI. The stackTrace looks like:

System.NotSupportedException: The invoked member is not supported in a dynamic assembly.
at Oracle.DataAccess.Types.OracleUdt.GetAllReferencedAssemblies()
at Oracle.DataAccess.Client.RegAndConfigRdr.setudtmapping(Hashtable& s_mapUdtNameToMappingObj)
at System.Reflection.Emit.InternalAssemblyBuilder.get_Location()
at Oracle.DataAccess.Types.OracleUdt.SetCustomTypeMappings()
at Oracle.DataAccess.Types.OracleUdt.GetUdtName(String customTypeName, String dataSource)
at Oracle.DataAccess.Client.OracleParameter.SetUDTFromCustomObject(OracleConnection conn, IOracleCustomType customObj, Int32 i)
at Oracle.DataAccess.Client.OracleParameter.PreBind_OracleObject(OracleConnection conn)
at Oracle.DataAccess.Client.OracleParameter.PreBind_Object(OracleConnection conn)
at Oracle.DataAccess.Client.OracleParameter.PreBind(OracleConnection conn, IntPtr errCtx, Int32 arraySize)
at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)
at Oracle.DataAccess.Client.OracleCommand.ExecuteReader()

my coworkers didn't experience this problem so I figure it has something to do with my local machine.

I looked up the Oracle.DataAccess.dll in GAC, it looks like (I used .Net 4.0, under c:/windows/Microsoft.NET/assembly):

find . -name "Oracle.*DataAccess*.dll"
./GAC_32/Oracle.DataAccess/v4.0_4.121.2.0__89b483f429c47342/Oracle.DataAccess.dll
./GAC_MSIL/Oracle.ManagedDataAccess/v4.0_4.121.2.0__89b483f429c47342/Oracle.ManagedDataAccess.dll

My coworkers used: V2.121.3.0 and no managed dll. The reason why my DLL being different from theirs is that I use VS2015 vs. they VS2013, and it took me a while to figure out the right (at least by that time) Oracle DLLs that get the app built and run under VS2015.

The closest post is here: Passing Oracle UDT to stored procedure throws error on ExecuteNonQuery but it didn't have a solution.

解决方案

In case anyone still have this issue. The same thing happened to me when I tried to upgrade Oracle Driver from 11.* to 12.*.

I found that at runtime, it load both 2.12* and 4.12* Oracle.DataAccess assembly from GAC.

The quick solution is simply do a runtime assembly redirect to 4.12* since our app target at .Net Framework 4.*. My preferred solution is migrate to use Managed Oracle Driver NuGet version.

I still didn't figure out why it throw the exception even if in the dll they checked (!assembly.IsDynamic ) as @AardVark71 mentioned. But that line "assembly.Location" is introduced in 12.* Oracle Driver. Also not quite sure why it loaded two version of Oracle.DataAccess Assembly

这篇关于与Oracle DataAccess有关:“动态程序集不支持被调用的成员."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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