Oracle DataAccess related: “The invoked member is not supported in a dynamic assembly.”

跟風遠走 提交于 2020-01-15 04:26:47

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/37889849/oracle-dataaccess-related-the-invoked-member-is-not-supported-in-a-dynamic-ass

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!