-1

i'm developing in vs2012 with oracle database and Entity Framework 6.0, using Devart.Data.Oracle to connect to database. in the last deploy i get this error, "Devart.Data.Oracle.OracleConnection cannot be cast to..." only when running on server. on the local machine + debuging mode, everything go OK.

i gess its relatate to Devart or Entityframework upgrade, and maybe related to the app.config file. but All attempts have failed. the full error message: Batch Console : [A]Devart.Data.Oracle.OracleConnection cannot be cast to [B]Devart.Data.Oracle.OracleConnection. Type A originates \ from 'Devart.Data.Oracle, Version=8.1.36.0, Culture=neutral, PublicKeyToken=09af7300eec23701' in the context 'Default' at location \ 'C:\Windows\assembly\GAC_MSIL\Devart.Data.Oracle\8.1.36.0__09af7300eec23701\Devart.Data.Oracle.dll'. Type B originates from 'Devart\ .Data.Oracle, Version=9.7.770.0, Culture=neutral, PublicKeyToken=09af7300eec23701' in the context 'Default' at location '\vsrvmink\ un\VMIKUN\mikunjr\PVN\ctm01_mushlach_yomi\test\Status_Tst\Devart.Data.Oracle.dll'.

the config file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <section name="ParallelRun.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
        </sectionGroup>
      <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="ParallelRun.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        </sectionGroup>
    </configSections>
  <connectionStrings>   
    <add name="PVNEntitiesConnectionString" connectionString="metadata=res://*/DataModelContex.csdl|res://*/DataModelContex.ssdl|res://*/DataModelContex.msl;provider=Devart.Data.Oracle;provider connection string=&quot;User Id=pvn;Password=pvn;Server=test;Direct=True;Sid=test;Persist Security Info=True&quot;" providerName="System.Data.EntityClient"/>

    <userSettings>      
        <ParallelRun.Properties.Settings>
            <setting name="DeleteBeforeRun" serializeAs="String">
                <value>delete from pvn_tnuot</value>
            </setting>
            <setting name="DeleteBeforeDS" serializeAs="String">
                <value />
            </setting>
            <setting name="ExportCommand" serializeAs="String">
                <value />
            </setting>
        </ParallelRun.Properties.Settings>
    </userSettings>
  <system.data>
    <DbProviderFactories>
      <!--<remove invariant="Devart.Data.Oracle"/>
      <add name="dotConnect for Oracle" invariant="Devart.Data.Oracle" description="Devart dotConnect for Oracle" type="Devart.Data.Oracle.OracleProviderFactory, Devart.Data.Oracle, Version=9.7.770.0, Culture=neutral, PublicKeyToken=09af7300eec23701"/>-->
    </DbProviderFactories>
  </system.data>
  <entityFramework>
    <providers>
      <provider invariantName="Devart.Data.Oracle" type="Devart.Data.Oracle.Entity.OracleEntityProviderServices, Devart.Data.Oracle.Entity.EF6, Version=9.7.770.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
    </providers>
  </entityFramework>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup>
  <applicationSettings>
    <ParallelRun.Properties.Settings>
      <setting name="LogFileName" serializeAs="String">
        <value>BatchLogTs</value>
      </setting>
    </ParallelRun.Properties.Settings>
  </applicationSettings>
</configuration>

the first line code openning connection to database is very simple: int bankscounter = DataAccess.Instance.CountBanks(); at this point all the connection components are loaded, and i get this error. any help/sעggestions are welkome.

  • The error mentions two different versions. Could that be the issue? – mjwills Jun 17 '20 at 06:54
  • Please open Package Manager in VS and go to the `Consolidate` tab. How many entries are there? – mjwills Jun 17 '20 at 06:54
  • Looks like you have two version of Devart driver installed. 8.1.36 and 9.7.770. I would recommend to remove them all properly and make **one** fresh installation. Use [gacutil](https://learn.microsoft.com/en-us/dotnet/framework/tools/gacutil-exe-gac-tool) to verify if they have been properly removed from GAC. – Wernfried Domscheit Jun 17 '20 at 08:56

1 Answers1

0
  1. Check provider registration in global and application config files: https://forums.devart.com/viewtopic.php?t=33320#p115587.
  2. Are there Devart.* and policy.*.Devart.* files in your GAC?
  3. Check the versions of Devart.* assemblies in the folder of your application and in GAC.
Devart
  • 119,203
  • 23
  • 166
  • 186