Page 1 of 1

[A]Devart.Data.Oracle.OracleCommand cannot be cast to [B]Devart.Data.Oracle.OracleCommand

Posted: Thu 09 Dec 2021 19:56
by hepek
I developed a program and it is working fine on my PC. when I deploy it to the server I get the following error:

Code: Select all

[A]Devart.Data.Oracle.OracleCommand cannot be cast to [B]Devart.Data.Oracle.OracleCommand. 
Type A originates from 'Devart.Data.Oracle, Version=9.11.1034.0, Culture=neutral, PublicKeyToken=09af7300eec23701' in the context 'Default' at location 'C:\Windows\assembly\GAC_MSIL\Devart.Data.Oracle\9.11.1034.0__09af7300eec23701\Devart.Data.Oracle.dll'. 
Type B originates from 'Devart.Data.Oracle, Version=9.14.1382.0, Culture=neutral, PublicKeyToken=09af7300eec23701' in the context 'Default' at location 'E:\PollingDSP\UAT\Devart.Data.Oracle.dll'. at Devart.Data.Oracle.Linq.Provider.OracleDataProvider.CreateCommand(String commandText, IDbConnection connection, Boolean forBatch)
at Devart.Data.Linq.DataProvider.a(av A_0, Object[] A_1)
at Devart.Data.Linq.Engine.DataQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

Re: [A]Devart.Data.Oracle.OracleCommand cannot be cast to [B]Devart.Data.Oracle.OracleCommand

Posted: Thu 09 Dec 2021 19:58
by hepek
I would expect all devart DLLs to be included with my app, but they are not.

Re: [A]Devart.Data.Oracle.OracleCommand cannot be cast to [B]Devart.Data.Oracle.OracleCommand

Posted: Fri 10 Dec 2021 16:37
by hepek
I think the issue is with different versions of devart:

Type A originates from 'Devart.Data.Oracle, Version=9.11.1034.0, Culture=neutral, PublicKeyToken=09af7300eec23701' in the context 'Default' at location 'C:\Windows\assembly\GAC_MSIL\Devart.Data.Oracle\9.11.1034.0__09af7300eec23701\Devart.Data.Oracle.dll'.
Type B originates from 'Devart.Data.Oracle, Version=9.14.1382.0, Culture=neutral, PublicKeyToken=09af7300eec23701' in the context 'Default' at location 'E:\PollingDSP\UAT\Devart.Data.Oracle.dll'.

Re: [A]Devart.Data.Oracle.OracleCommand cannot be cast to [B]Devart.Data.Oracle.OracleCommand

Posted: Sat 11 Dec 2021 12:24
by Shalex
Have you added the <publisherPolicy apply="no"/> entry for the Devart.* references in *.config of your application?
This should make CLR to ignore policy.*.Devart.* files from GAC 2.0 (\Windows\assembly\GAC_MSIL\) and GAC 4.0 (\Windows\Microsoft.NET\assembly\GAC_MSIL\).

If this doesn't help, uninstall dotConnect for Oracle from your deployment server to remove Devart.* assemblies from GAC 2.0 and GAC 4.0.

Re: [A]Devart.Data.Oracle.OracleCommand cannot be cast to [B]Devart.Data.Oracle.OracleCommand

Posted: Mon 13 Dec 2021 15:30
by hepek
I do not have any entry in my app.config file related to devart.

can you please provide that config entry with <publisherPolicy apply="no"/>?

btw - I don't thik I ever installed devart on this server. is there a way to tell devart NOT to use GAC?
in another words - may I deploy the app in a way that it does not need devart installation at all.

Re: [A]Devart.Data.Oracle.OracleCommand cannot be cast to [B]Devart.Data.Oracle.OracleCommand

Posted: Tue 14 Dec 2021 13:43
by Shalex
hepek wrote: Mon 13 Dec 2021 15:30 can you please provide that config entry with <publisherPolicy apply="no"/>?
1. Here is:

Code: Select all

<configuration>  
   <runtime>  
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
         <dependentAssembly>  
            <assemblyIdentity name="Devart.Data"  
                                    publicKeyToken="09af7300eec23701"  
                                    culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-5.0.2806.0" newVersion="5.0.2806.0"/>
            <publisherPolicy apply="no"/>  
         </dependentAssembly>
         <dependentAssembly>  
            <assemblyIdentity name="Devart.Data.Oracle"  
                                    publicKeyToken="09af7300eec23701"  
                                    culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-9.14.1382.0" newVersion="9.14.1382.0"/>
            <publisherPolicy apply="no"/>  
         </dependentAssembly>
         <dependentAssembly>  
            <assemblyIdentity name="Devart.Data.Linq"  
                                    publicKeyToken="09af7300eec23701"  
                                    culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.9.2351.0" newVersion="4.9.2351.0"/>
            <publisherPolicy apply="no"/>  
         </dependentAssembly>
         <dependentAssembly>  
            <assemblyIdentity name="Devart.Data.Oracle.Linq"  
                                    publicKeyToken="09af7300eec23701"  
                                    culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.9.2351.0" newVersion="4.9.2351.0"/>
            <publisherPolicy apply="no"/>  
         </dependentAssembly>
      </assemblyBinding>  
   </runtime>  
</configuration>  
hepek wrote: Mon 13 Dec 2021 15:30 btw - I don't thik I ever installed devart on this server.
2. The error says that one Devart.Data.Oracle.dll is loaded from GAC. Search for dotConnect for Oracle in the "Add or remove programs" utility of your Windows.
hepek wrote: Mon 13 Dec 2021 15:30 is there a way to tell devart NOT to use GAC?
3. GAC is the first location where CLR looks for the assembly.
hepek wrote: Mon 13 Dec 2021 15:30 in another words - may I deploy the app in a way that it does not need devart installation at all.
4. Yes, you may. Refer to https://www.devart.com/dotconnect/oracl ... yment.html.