This discussion is archived
1 Reply Latest reply: Jul 11, 2013 3:06 PM by Alex_Keh - Oracle_Product_Manager RSS

ODP.NET configuration confusion

maciej.milczarek Newbie
Currently Being Moderated

Hi,

 

I have two computers: one for development purposes (Visual Studio + ODP.NET managed installed) and second one for testing (no ODP.NET). I developed an application which works fine using oracle.managedDataAccess.dll but there is a problem regarding configuration file (app.config).

 

When I run my app on development computer everything works ok. There is oracle section in app.config:

 

  <oracle.manageddataaccess.client>
    <version number="*">
      <dataSources>
        <dataSource alias=... "/>
      </dataSources>
      <settings>
        <setting name="TraceOption" value="1"/>
        <setting name="PerformanceCounters" value="0" />  
      </settings>
    </version>
  </oracle.manageddataaccess.client>

When I try to run it on testing machine I get Unrecognized configuration section Exception. To solve this problem I need to add following line to app.config:

 

<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess" />

 

Then, application runs on testing machine, but on development machine I get Section or group name 'oracle.manageddataaccess.client' is already defined Exception. I tried to workaround it by removing duplicated section from config at runtime:

 

private void AdjustConfiguration()
{
    string sectionKey = "oracle.manageddataaccess.client";
    Configuration config = ConfigurationManager.OpenMachineConfiguration();
  
    var sections = config.Sections.Keys.OfType<string>().Where(c => c == sectionKey).ToList();
  
    if (sections.Any())
    {
        sections.ForEach(s => config.Sections.Remove(sectionKey));
    }
}

Solution above used to work with ODP.NET Beta 2, now with final release (4.121.1) it doesn't work - I still get duplicated section exception after section removal.

 

Does anyone have a solution how to keep the same app.config for development and testing purposes? Perhaps I'm doing something wrong?

  • 1. Re: ODP.NET configuration confusion
    Alex_Keh - Oracle_Product_Manager Expert
    Currently Being Moderated

    The <section name="oracle.manageddataaccess....> XML gets added as part of the install process. You don't seem to have run the installer on your testing machine, which is the reason for the error. My suggested solution is to just run the installer on your testing machine and you should be fine. If you want to install via xcopy, that's fine. Just don't forget to run the configuration script.

     

    The other way to ensure your app.configs are the same is to move the XML you added to the app.config to the machine.config. You would then be able to have the same app.config info...and even the same machine.config info presumably.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points