Issues with Deployment

Issues with Deployment

Postby spettifer » Tue 10 Apr 2012 13:56

Hi

I am using the trial version of dotConnect for Oracle to see if it is a suitable replacement for the .Net framework intrinsic Oracle client in our applications, as we want to remove the dependency on the Oracle Client on client workstations. I have installed dotConnect and looked at the Data Access Quick Start sample to see how it all hung together. I knocked up a small test app using VS2010 targeting Framework 3.5 (as we do with our apps) and having added the appropriate bits to the app.config for provider mapping etc it all worked beautifully (I should add we use Enterprise Library 5 for managing database objects etc). I then added a simple setup and deployment project to build a simple installer and ran it, again on my development machine, and all worked as expected.

However, I have all sorts of stuff installed on my dev machine including the Oracle client so in order to test that it would truly work as we wanted it I installed the test app onto a VM with a vanilla install of Win 7 x86. The installer seemed to put in everything the app requires and the app itself starts. However when I click the 'Test' button (which should simple execute a simple statement and display the results), I get an Enterprise Library exception whcih is one of the less helpful ones that EL can throw:

Microsoft.Practices.ServiceLocation.ActivationException: Activation error occured while trying to get instance of type Database, key "Testing26_devart" ---> Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Data.Database", name = "Testing26_devart".


I have had that error before with EL but all the usual suspects don't seem to apply here as I know for certain that the environment name in the config is the one being requested and so on, plus as I say this works perfectly on my development machine.

I should point out a few things about how we utilise EL. We do not use the provider factory classes, instead we use the EL5 recommended way of obtaining a database instance:

Code: Select all
Dim db As Database = EnterpriseLibraryContainer.Current.GetInstance(Of Database)(EnvironmentName)


EnvironmentName is the name of the entry in the ConnectionStrings collection in the app.config that I wish to use. That entry looks like this:

Code: Select all
<add name="Testing26_devart" connectionString="User Id=Testing26;Password=Testing26;Server=Oracle-Server;Direct=True;Sid=DEVORA;Port=1523;" providerName="Devart.Data.Oracle"/>


My provider mapping:

Code: Select all
<dataConfiguration>
        <providerMappings>
            <add databaseType="Devart.Data.Oracle.EnterpriseLibrary.OracleDatabase, Devart.Data.Oracle.EnterpriseLibrary" name="Devart.Data.Oracle" />
        </providerMappings>
    </dataConfiguration>


My references include the following:

    Devart.Data
    Devart.Data.Oracle
    Devart.Data.Oracle.EnterpriseLibrary
    Microsoft.Practices.EnterpriseLibrary.Common
    Microsoft.Practices.EnterpriseLibrary.Data
    Microsoft.Practices.ServiceLocation
    Microsoft.Practices.Unity.Configuration

The deployment project puts the built executable, the Myapp.exe.config and all the dependencies in the same folder.

I checked then license wizard and clicked on the Fix button to ensure the license.licx file was included in the test app project (although it doesn't appear in the built output as far as I can see - should it?).

Can anyone suggest what I might be doing wrong? I can provide any more information that is required. I really want to get this working as I am keen to get our applications away from using the Oracle Client, as is my boss (they must be as they've agreed to stump up for the full version so long as the proof-of-concept works!).

Many thanks

Steve Pettifer
spettifer
 
Posts: 3
Joined: Tue 10 Apr 2012 13:18

Extra Information

Postby spettifer » Tue 10 Apr 2012 14:44

I should probably point out that our apps are intended to target multiple DB platforms. Although we mainly use SQL Server we also have to support Oracle, hence this work. Therefore we do not use any specialised features of the derived classes such as SQLDatabase or OracleDatabase - we try and keep everything generic.
spettifer
 
Posts: 3
Joined: Tue 10 Apr 2012 13:18

Postby Shalex » Thu 12 Apr 2012 12:47

We have reproduced this error in our test environment. Here are two steps to resolve it:
1. Run the Tools > Oracle > License Information wizard and let it to embed the license resource into output assembly, rebuild the project.
2. Make sure that you have registered dotConnect for Oracle in DbProviderFactories. An example of working App.config:
Code: Select all
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data" />
  </configSections>
  <connectionStrings>
    <add
      name="Testing26_devart"
      providerName="Devart.Data.Oracle"
      connectionString="User Id=Testing26;Password=Testing26;Server=Oracle-Server;Direct=True;Sid=DEVORA;Port=1523;" />
  </connectionStrings>
  <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=6.80.341.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
    </DbProviderFactories>
  </system.data>
  <dataConfiguration defaultDatabase="Testing26_devart">
    <providerMappings>
      <add
      databaseType="Devart.Data.Oracle.EnterpriseLibrary.OracleDatabase, Devart.Data.Oracle.EnterpriseLibrary"
      name="Devart.Data.Oracle" />
    </providerMappings>
  </dataConfiguration>
</configuration>
Shalex
Devart Team
 
Posts: 7391
Joined: Thu 14 Aug 2008 12:44

Postby spettifer » Thu 12 Apr 2012 13:45

Hi

Had already done the licenses, but got to the provider factories issue independently, and adding the DbProviderFactory entry to the app.config did indeed fix the problem, thanks. It might be worth making clear in the Deployment section of your documentation that you need to add this section to app.config whether you either directly reference the DbProviderFactory classes or use the new Enterprise Library 5 way of doing things with
Code: Select all
EnterpriseLibraryContainer.Current.GetInstance


Given that this is something of an abstraction of the provider factories it is not immediately obvious that it uses the same thing under the covers, so to speak (even in the source code, unless you spend ages trawling it - which I did!), so an example of both ways -
Code: Select all
EnterpriseLibraryContainer.Current.GetInstance
and
Code: Select all
DatabaseProviderFactory.Create
would help a lot for clarity. Might also be worth mentioning this in the section on Enterprise Library too.

Many thanks for the reply and the suggestions. Now my next task - adding nHibernate into the proof of concept as well!!

Cheers

Steve
spettifer
 
Posts: 3
Joined: Tue 10 Apr 2012 13:18

Postby Shalex » Fri 13 Apr 2012 09:44

spettifer wrote:It might be worth making clear in the Deployment section of your documentation that you need to add this section to app.config whether you either directly reference the DbProviderFactory classes or use the new Enterprise Library 5 way of doing things ...

Please refer to http://www.devart.com/dotconnect/oracle/docs/?Deployment.html:
"When your code uses dotConnect for Oracle via a factory-based class, you should register configuration information in the DbProviderFactories section ..."

We will add the corresponding sample to http://www.devart.com/dotconnect/oracle/docs/?EnterpriseLib.html. Thank you for your suggestion.
Shalex
Devart Team
 
Posts: 7391
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle