When using System.Data.Common.DbProviderFactory with we get this error when we run our code in an NUnit test but not when we run the regular web application.
Error
System.InvalidCastException : [A]Oracle.DataAccess.Client.OracleParameter cannot be cast to [B]Oracle.DataAccess.Client.OracleParameter. Type A originates from 'Oracle.DataAccess, Version=2.112.1.2, Culture=neutral, PublicKeyToken=89b483f429c47342' in the context 'Default' at location 'C:\Windows\assembly\GAC_32\Oracle.DataAccess\2.112.1.2__89b483f429c47342\Oracle.DataAccess.dll'. Type B originates from 'Oracle.DataAccess, Version=4.112.1.2, Culture=neutral, PublicKeyToken=89b483f429c47342' in the context 'Default' at location 'C:\Windows\Microsoft.Net\assembly\GAC_32\Oracle.DataAccess\v4.0_4.112.1.2__89b483f429c47342\Oracle.DataAccess.dll'.
We have the 2.112.1.2 assembly referenced by the unit test project and we even tried 'use specific version' and 'copy local' but it just doesn't see that DLL it continues to load from a newer version in the GAC.