PInvoke Invalid Metadata on Oracle connect

  • Glenn E. Lanier, II

    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\\\', No symbols loaded.
    'PatientTracking.exe': Loaded 'c:\windows\assembly\gac\\\', No symbols loaded.
    'PatientTracking.exe': Loaded 'c:\windows\assembly\gac\\\', No symbols loaded.
    'PatientTracking.exe': Loaded 'c:\windows\assembly\gac\\1.0.5000.0__b77a5c561934e089\', 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!


    • 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:


      • Glenn E. Lanier, II

        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 section. -->
          <!-- Used to access the other parts of the configuration file. -->
            <sectionGroup name="MimerProviderManager">
              <section name="dataSources" type="Mimer.Mpm.Data.ConfigFile.MpmDataSourceSectionHandler,Mimer.Mpm.Data.ConfigFile, Version=, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
              <section name="plugins" type="Mimer.Mpm.Data.ConfigFile.MpmPluginDescriptorSectionHandler,Mimer.Mpm.Data.ConfigFile, Version=, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
              <section name="sqlFilters" type="Mimer.Mpm.Data.ConfigFile.MpmSqlFilterDescriptorSectionHandler,Mimer.Mpm.Data.ConfigFile, Version=, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
          <!-- Application settings section. -->
          <!-- You can add your own application specific settings here. -->
            <add key="Mpm Configuration" value="Mimer.Mpm.Data.ConfigFile.MpmConfigStartup, Mimer.Mpm.Data.ConfigFile, Version=, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
            <!-- Data Source section. -->
              <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" />
            <!-- Plugin section. -->
              <plugin pluginName="MsOracle" factoryClass="MpmMsOracleFactory" factoryNamespace="Mimer.Mpm.Data.MsOraclePlugin" factoryAssembly="Mimer.Mpm.Data.MsOraclePlugin, Version=, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
              <plugin pluginName="Oracle9" factoryClass="MpmOracle9Factory" factoryNamespace="Mimer.Mpm.Data.Oracle9Plugin" factoryAssembly="Mimer.Mpm.Data.Oracle9Plugin, Version=, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
              <plugin pluginName="Sql" factoryClass="MpmSqlFactory" factoryNamespace="Mimer.Mpm.Data.SqlPlugin" factoryAssembly="Mimer.Mpm.Data.SqlPlugin, Version=, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
              <plugin pluginName="Generic Odbc" factoryClass="MpmGenericFactory" factoryNamespace="Mimer.Mpm.Data.GenericPlugin" factoryAssembly="Mimer.Mpm.Data.GenericPlugin, Version=, 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 pluginName="OleDb" factoryClass="MpmOleDbFactory" factoryNamespace="Mimer.Mpm.Data.OleDbPlugin" factoryAssembly="Mimer.Mpm.Data.OleDbPlugin, Version=, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
              <plugin pluginName="Mimer" factoryClass="MpmMimerFactory" factoryNamespace="Mimer.Mpm.Data.MimerPlugin" factoryAssembly="Mimer.Mpm.Data.MimerPlugin, Version=, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
              <plugin pluginName="Odbc" factoryClass="MpmOdbcFactory" factoryNamespace="Mimer.Mpm.Data.OdbcPlugin" factoryAssembly="Mimer.Mpm.Data.OdbcPlugin, Version=, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
            <!-- SQL Filter section. -->
              <sqlFilter sqlFilterName="ParameterMarkers" factoryClass="MpmSqlFilterParameterMarkers" factoryNamespace="Mimer.Mpm.Data.SqlFilterParameterMarkers" factoryAssembly="Mimer.Mpm.Data.SqlFilterParameterMarkers, Version=, Culture=neutral, PublicKeyToken=90474c83ee7ec777" />
        -- 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;
                        //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");
                        tableCommand = mpmConnection.CreateCommand();

        What else do you need?

        • 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).

          • Glenn E. Lanier, II

            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.


    • 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 of the Oracle Data Provider and Oracle10 have been tested with versoin
      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.


      • Glenn E. Lanier, II

        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!


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks