0
votes

I'm converting to VS2017 a legacy project which uses a database connection dialog to collect data to format a connection string.

This line below is triggering an error:

var dialog = new DataConnectionDialog();

Could not load file or assembly 'Microsoft.Data.ConnectionUI, Version=0.0.0.0, Culture=neutral, PublicKeyToken=f4ca07f51760da93' or one of its dependencies. The system cannot find the file specified.: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Data.ConnectionUI, Version=0.0.0.0, Culture=neutral, PublicKeyToken=f4ca07f51760da93' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.Data.ConnectionUI, Version=0.0.0.0, Culture=neutral, PublicKeyToken=f4ca07f51760da93' at Microsoft.Data.ConnectionUI.DataConnectionDialog..ctor() at Wings4CloudPackage.Forms.frmNewSolution.btnDatabase_Click(Object sender, EventArgs e)

=== Pre-bind state information === LOG: DisplayName = Microsoft.Data.ConnectionUI, Version=0.0.0.0, Culture=neutral, PublicKeyToken=f4ca07f51760da93 (Fully-specified) LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/ LOG: Initial PrivatePath = NULL Calling assembly : Microsoft.Data.ConnectionUI.Dialog, Version=0.0.0.0, Culture=neutral, PublicKeyToken=f4ca07f51760da93. === LOG: This bind starts in LoadFrom load context. WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().

I have checked this path: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/ and the referenced Microsoft.Data.ConnectionUI.dll is there.

This project uses the following nuget package to show the dialog: DataConnectionDialog (https://www.nuget.org/packages/DataConnectionDialog/1.1.0)

This code works in VS2013, but not in VS2017.

1
Can you run inside of Dependency Walker (use it instead of a debugger). www.dependencywalker.com If one of the files that Microsoft.Data.ConnectionUI.dll requires is missing, that should help identify it.Ben Voigt
Try to start Fuslogvw - DLL binding debugger - and check where VS tries to load the DLL from.Ferdipux

1 Answers

0
votes

For me in VS 2017 in WPF app works this:

        DataConnectionDialog dcd = new DataConnectionDialog();

        DataProvider dataProviderSql = DataProvider.SqlDataProvider;
        DataSource dataSourceSql = new DataSource(dataProviderSql.Name, dataProviderSql.DisplayName);
        dataSourceSql.Providers.Add(dataProviderSql);

        DataProvider dataProviderOracle = DataProvider.OracleDataProvider;
        DataSource dataSourceOracle = new DataSource(dataProviderOracle.Name, dataProviderOracle.DisplayName);
        dataSourceOracle.Providers.Add(dataProviderOracle);

        DataProvider dataProviderOle = DataProvider.OleDBDataProvider;
        DataSource dataSourceOle = new DataSource(dataProviderOle.Name, dataProviderOle.DisplayName);
        dataSourceOle.Providers.Add(dataProviderOle);

        DataProvider dataProviderOdbc = DataProvider.OdbcDataProvider;
        DataSource dataSourceOdbc = new DataSource(dataProviderOdbc.Name, dataProviderOdbc.DisplayName);
        dataSourceOdbc.Providers.Add(dataProviderOdbc);


        dcd.DataSources.Add(dataSourceSql);
        dcd.DataSources.Add(dataSourceOracle);
        dcd.DataSources.Add(dataSourceOle);
        dcd.DataSources.Add(dataSourceOdbc);

        dcd.SelectedDataSource = dataSourceSql;
        dcd.SelectedDataProvider = dataProviderSql;

        if (DataConnectionDialog.Show(dcd) == System.Windows.Forms.DialogResult.OK)
        {
            System.Windows.MessageBox.Show("YES");
        }