Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

PInvoke Invalid Metadata on Oracle connect

Help
2005-09-22
2013-04-24
  • I am trying to connect to an Oracle DB using Mimer. I'm getting the following error when I execute the MpmConnection.Open.

    When I use a SQL server connection string, it connects properly. Any ideas?

    -- Debug output and exception.ToString output:
    'PatientTracking.exe': Loaded 'c:\windows\assembly\gac\mimer.mpm.data.configfile\1.2.3.1__90474c83ee7ec777\mimer.mpm.data.configfile.dll', No symbols loaded.
    'PatientTracking.exe': Loaded 'c:\windows\assembly\gac\mimer.mpm.data.msoracleplugin\1.2.3.1__90474c83ee7ec777\mimer.mpm.data.msoracleplugin.dll', No symbols loaded.
    'PatientTracking.exe': Loaded 'c:\windows\assembly\gac\mimer.mpm.data.internal\1.2.3.1__90474c83ee7ec777\mimer.mpm.data.internal.dll', No symbols loaded.
    'PatientTracking.exe': Loaded 'c:\windows\assembly\gac\system.data.oracleclient\1.0.5000.0__b77a5c561934e089\system.data.oracleclient.dll', No symbols loaded.
    'PatientTracking.exe': Loaded 'c:\windows\assembly\gac\system.enterpriseservices\1.0.3300.0__b03f5f7f11d50a3a\system.enterpriseservices.dll', No symbols loaded.
    'PatientTracking.exe': Loaded 'c:\windows\assembly\gac\system.enterpriseservices\1.0.3300.0__b03f5f7f11d50a3a\system.enterpriseservices.thunk.dll', No symbols loaded.
    Error: System.TypeLoadException: Invalid PInvoke metadata format.
       at Mimer.Mpm.Data.Internal.MpmPluginConnection.Open()
       at Mimer.Mpm.Data.MpmConnection.Open()
    -- End of debug and exception output

    I'm connecting to an Oracle 10 database (the Mimer Provider Administrator can successfully connect -- so I *assumed* my drivers and connection string were good).

    I don't know about the ADO.NET provider for Oracle -- I did install the Oracle OraClient10g package. What should I look for on my XP system?

    Connection string:
          <dataSource dataSourceName="Oracle_Test" pluginName="MsOracle" connectionString="Data Source=SUN9;User Id=validuser;Password=validpassword;" dbmsTypeName="Oracle" />

    Any additional help is greatly appreciated!

    --G

     
    • Bengt Gunne
      Bengt Gunne
      2005-09-22

      Since you are able to connect using the administrator we need to figure out what the difference is between the connect there and in your application.

      From the traceback it looks like you have a configuration file for your application. Were you using this file in the administrator too? Otherwise you are possibly using different connection strings in the two cases:

      Bengt

       
      • Yes. I used the administrator to create the config file. When creating the datasource, I used the "test" feature to make sure I had it set up correctly. It connected.

        I did make a change to the config file after saving -- I changed the type of the MimerProviderManager.sqlFilters from ...MpmSqlFilterSectionHandler... to ...MpmSqlFilterDescriptorSectionHandler... Do you think that is causing the problem (that makes the SQL server connection work)?

        -- entire .exe.config file, with only username/password changed:
        <?xml version="1.0" encoding="utf-8"?>
        <configuration>
          <!---->
          <!-- Configuration section. -->
          <!-- Used to access the other parts of the configuration file. -->
          <!---->
          <configSections>
            <sectionGroup name="MimerProviderManager">
              <section name="dataSources" type="Mimer.Mpm.Data.ConfigFile.MpmDataSourceSectionHandler,Mimer.Mpm.Data.ConfigFile, Version=1.2.3.1, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
              <section name="plugins" type="Mimer.Mpm.Data.ConfigFile.MpmPluginDescriptorSectionHandler,Mimer.Mpm.Data.ConfigFile, Version=1.2.3.1, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
              <section name="sqlFilters" type="Mimer.Mpm.Data.ConfigFile.MpmSqlFilterDescriptorSectionHandler,Mimer.Mpm.Data.ConfigFile, Version=1.2.3.1, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
            </sectionGroup>
          </configSections>
          <!---->
          <!-- Application settings section. -->
          <!-- You can add your own application specific settings here. -->
          <!---->
          <appSettings>
            <add key="Mpm Configuration" value="Mimer.Mpm.Data.ConfigFile.MpmConfigStartup, Mimer.Mpm.Data.ConfigFile, Version=1.2.3.1, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
          </appSettings>
          <MimerProviderManager>
            <!---->
            <!-- Data Source section. -->
            <!---->
            <dataSources>
              <dataSource dataSourceName="Oracle_Test" pluginName="MsOracle" connectionString="Data Source=dbinstance;User Id=validuser;Password=validpassword;" dbmsTypeName="Oracle" />
              <dataSource dataSourceName="SQL_GEL" pluginName="Sql" connectionString="Server=(local);User Id=validuser;Password=validpassword;Database=dbname;" dbmsTypeName="Sql Server" />
            </dataSources>
            <!---->
            <!-- Plugin section. -->
            <!---->
            <plugins>
              <plugin pluginName="MsOracle" factoryClass="MpmMsOracleFactory" factoryNamespace="Mimer.Mpm.Data.MsOraclePlugin" factoryAssembly="Mimer.Mpm.Data.MsOraclePlugin, Version=1.2.3.1, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
              <plugin pluginName="Oracle9" factoryClass="MpmOracle9Factory" factoryNamespace="Mimer.Mpm.Data.Oracle9Plugin" factoryAssembly="Mimer.Mpm.Data.Oracle9Plugin, Version=1.2.3.1, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
              <plugin pluginName="Sql" factoryClass="MpmSqlFactory" factoryNamespace="Mimer.Mpm.Data.SqlPlugin" factoryAssembly="Mimer.Mpm.Data.SqlPlugin, Version=1.2.3.1, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
              <plugin pluginName="Generic Odbc" factoryClass="MpmGenericFactory" factoryNamespace="Mimer.Mpm.Data.GenericPlugin" factoryAssembly="Mimer.Mpm.Data.GenericPlugin, Version=1.2.3.1, Culture=neutral, PublicKeyToken=90474c83ee7ec777">
                <genericInfo genericPrefix="Odbc" genericNamespace="System.Data.Odbc" genericAssemblyName="System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" parameterMarker="?" />
              </plugin>
              <plugin pluginName="OleDb" factoryClass="MpmOleDbFactory" factoryNamespace="Mimer.Mpm.Data.OleDbPlugin" factoryAssembly="Mimer.Mpm.Data.OleDbPlugin, Version=1.2.3.1, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
              <plugin pluginName="Mimer" factoryClass="MpmMimerFactory" factoryNamespace="Mimer.Mpm.Data.MimerPlugin" factoryAssembly="Mimer.Mpm.Data.MimerPlugin, Version=1.2.3.1, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
              <plugin pluginName="Odbc" factoryClass="MpmOdbcFactory" factoryNamespace="Mimer.Mpm.Data.OdbcPlugin" factoryAssembly="Mimer.Mpm.Data.OdbcPlugin, Version=1.2.3.1, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
            </plugins>
            <!---->
            <!-- SQL Filter section. -->
            <!---->
            <sqlFilters>
              <sqlFilter sqlFilterName="ParameterMarkers" factoryClass="MpmSqlFilterParameterMarkers" factoryNamespace="Mimer.Mpm.Data.SqlFilterParameterMarkers" factoryAssembly="Mimer.Mpm.Data.SqlFilterParameterMarkers, Version=1.2.3.1, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
            </sqlFilters>
          </MimerProviderManager>
        </configuration>
        -- end of entire .exe config file.

        The code that has trouble:
            Mimer.Mpm.Data.MpmConnection mpmConnection = new MpmConnection();
                    mpmConnection.ConnectionString = string.Format("Data Source Name={0}", "Oracle_Test");
                    MpmCommand tableCommand = null;
                    MpmDataReader reader = null;
                    try
                    {
                        //The connection should not be open when we get here
                        if(mpmConnection.State == ConnectionState.Open)
                        {
                            throw new Exception("The connection shouldn't be open here");
                        }
                        mpmConnection.Open();
                        tableCommand = mpmConnection.CreateCommand();

        What else do you need?
        --G

         
        • Bengt Gunne
          Bengt Gunne
          2005-09-22

          Everything looks ok. The error occurs outside Mpm, so I cannot tell you what is going wrong. Can you connect directly to Oracle (without Mpm) without problems? (If you like you can look at the ConnectionString passed to the OracleConnection in the debugger).

          The enterpriceservices dll is used for distributed context. Are you using com+? You can try setting Enlist to False in the connection string in the administrator and see if it has any effect. (Does not make sense why the administrator can connect).

           
          • Thanks for confirming it looks like I'm doing this correctly.

            I downloaded/installed the 154M Oracle Data Provider for .Net.

            I created a simple connect, read, close series to test connectivity. It works, no problems. However, switching to MPM still gives me the PInvoke Invalid Metadata when I try to open the connection.

            I pulled the _ConnectionString from the MpmConnection and used that exact format in my quick little test.

            Bottom line: Using OracleConnection, OracleCommand, and OracleDataReader allows me to connect to the database, while MpmConnection fails on my system.

            --G

             
    • Fredrik Ĺlund
      Fredrik Ĺlund
      2005-09-23

      Since you are using the plugin named MsOracle (pluginName="MsOracle" in the connection string) you are not using the Oracle Data Provider for .Net you installed but the Data Provider that comes with the .NET framework.

      To use the Oracle Data Provider for .Net you have installed you have to use the plugin Oracle9 or Oracle10. The Oracle9 plugin have been tested with version 9.2.0.4 of the Oracle Data Provider and Oracle10 have been tested with versoin 10.1.0.3.
      The Oracle10 plugin is not part of any of the binary distributions of Mpm yet, you have to fetch it from CVS and build it your self.

      /Fredrik

       
      • It looks like I'm going to have to build that then, as changing the OracleConnection from Oracle ODP to System.Data.OracleClient gives me the PInvoke Invalid Metadata error.

        I may be back with questions on building the plugin!