none
How can I figure out what config files are being used? RRS feed

  • Question

  • We have 1 user where on their machine, in the machine.config file (both .NET 2.0 & 4.0) it has:

    <system.data> 
    <DbProviderFactories> 
    <add name="Odbc Data Provider" invariant="System.Data.Odbc" 
    description=".Net Framework Data Provider for Odbc" 
    type="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, 
    Culture=neutral, PublicKeyToken=b77a5c561934e089"/> 
    <add name="OleDb Data Provider" invariant="System.Data.OleDb" 
    description=".Net Framework Data Provider for OleDb" 
    type="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, 
    Culture=neutral, PublicKeyToken=b77a5c561934e089"/> 
    <add name="OracleClient Data Provider" 
    invariant="System.Data.OracleClient" description=".Net Framework Data 
    Provider for Oracle" type="System.Data.OracleClient.OracleClientFactory, 
    System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, 
    PublicKeyToken=b77a5c561934e089"/> 
    <add name="SqlClient Data Provider" 
    invariant="System.Data.SqlClient" description=".Net Framework Data 
    Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, 
    System.Data, Version=2.0.0.0, Culture=neutral, 
    PublicKeyToken=b77a5c561934e089"/> 
    <add name="IBM DB2 for i .NET Provider" 
    invariant="IBM.Data.DB2.iSeries" description=".NET Framework Data Provider 
    for IBM i" type="IBM.Data.DB2.iSeries.iDB2Factory, IBM.Data.DB2.iSeries, 
    Version=12.0.0.0, Culture=neutral, PublicKeyToken=9cdb2ebfb1f93a26" /> 
    </DbProviderFactories> 
    </system.data>

    And in winword.exe.config (we're a Word AddIn) and AutoTag2010.dll.config (the name of our AddIn) there is no <DbProviderFactories> section.

    None of the above providers show up on a call to DbProviderFactories, not even the ODBC or OleDB connectors. How can I find out what other config files are in use when reading these?

    thanks - dave


    What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

    Tuesday, April 28, 2015 10:50 PM

All replies

  • Hello dave,

    As far as I know, a .NET application would only load a config file at a time, however, this file would be complex since it would override its parent setting. The inheritance relationship in these config files would be:

    Machine.config

      |

      |

      ----> app.config (application root)

                |

                |

                ---------> app.config (sub directories)

    And if it is a 32bit application, it would override the 32bit machine.config. For a 64bit application, it overrides the 64bit machine.config.

    I created a demo according to your description, by using a simple console application, and add these Providers entries to the machine.config, using below code to read them:

    var result = DbProviderFactories.GetFactoryClasses();

    I could get all entries. I notice that you are working with a work-addin project, I am not experienced with it, I suggest that you could confirm if it is caused by the add-in project on the office forum: https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=worddev

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, April 29, 2015 9:52 AM
    Moderator
  • What/where are the app.config files you mention? I know the app.exe.config (winword.exe.config in this case), but are there others? Your diagram makes it look like there are.

    thanks - dave


    What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

    Wednesday, April 29, 2015 2:38 PM
  • Hi Dave,

    From your description, it's a config file for a Word Addin application. From my eyes, the config file is related to access database.

    In your Word Addin application. Did you access the database as the config file pointed? If the answer is no. I am afraid this config file didn't use by your Word Addin application.

    In addition, this file maybe used by another software installed by user. Check the user machine, is there any database related software, maybe they used this config file.

    Thanks,


    The future belongs to those who believe in the beauty of their dreams.

    Thursday, April 30, 2015 2:58 AM
  • The problem is that DbProviderFactories.GetFactoryClasses() returns zero classes. Why is it returning no classes when the config file has 3 declared connectors in it?

    What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

    Thursday, April 30, 2015 2:31 PM
  • Hello Dave,

    >>but are there others? Your diagram makes it look like there are.

    The diagram is just used to show the inheritance relationship of these config file. In your case, it could be:

    Machine.config

      |

      |

      ---------> winword.exe.config

    >>Why is it returning no classes when the config file has 3 declared connectors in it?

    Could you please provide a detail information about your application environment: the add-in type, the .NET Framework version the project is built with, the IDE version and the system information. With these information, I would try to involve add-in experts to help if we can reproduce this issue. And I suggest you could check my original post, to make a simple console application and to check you could read these declared connectors by using DbProviderFactories.GetFactoryClasses() method, this would help narrow down this issue: if it is project type related.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, May 1, 2015 5:04 AM
    Moderator
  • We are calling DbProviderFactories.GetFactoryClasses() and it returns nothing. 

    And then that user updated their DB2 connector, and now all 3 show up. So somehow an older DB2 connector was stopping itself as well as the ODBC & OleDb connectors from showing up.


    What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

    Friday, May 1, 2015 1:57 PM
  • I misunderstood our customer. They still are seeing no connectors on some systems. Please tell me what other config files might exist and where they are located.

    Or any security or other settings that can change the connectors available.

    thanks - dave


    What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

    Friday, May 1, 2015 2:05 PM
  • Hello Dave,

    After confirming with a office work-in college, the add-in project could be an assembly, and is referenced by the word applicaiton, so i created a similar scenario: a console app to refer a class libray and in that class library proejct to read the providers, however, it still gets all providers including the new added IBM one. Since i cannot reproduce this issue, i am trying to invoke some one experienced to help look into this case, it may take some time and as soon as we get any result, we will tell you.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, May 4, 2015 8:17 AM
    Moderator
  • I had the same problem. I had a version of the oracle provider configured in machine config diferente from the version i wanted for my project. To solve that, in my app.config i included this:

    <system.data>
        <DbProviderFactories>
          <remove invariant="Oracle.DataAccess.Client" />
          <add name="Oracle Data Provider for .NET"
                  invariant="Oracle.DataAccess.Client"
                  description="Oracle Data Provider for .NET"
                  type="Oracle.DataAccess.Client.OracleClientFactory,
                      Oracle.DataAccess,
                      Version=2.111.7.20,
                      Culture=neutral,
                      PublicKeyToken=89b483f429c47342" />
        </DbProviderFactories>
      </system.data>


    In my case the problem was that i didn't iclude the line : 

          <remove invariant="Oracle.DataAccess.Client" />

    In this situation DbProviderFactories.GetFactoryClasses(); returns an empty datatable.

    After include that line it works for me.

    Also take in acount that there are a machine.config for x86 and another for x64.


    • Edited by Victor20000 Friday, October 7, 2016 12:20 PM
    Friday, October 7, 2016 12:19 PM