4
Vote

Could not load file or assembly 'Interop.MSDASC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

description

Running with VS 2010, Office 2010, SQL Server 2008 R2 under Windows 7 (x64) I was getting the below error. Looking into it, I found that if I made the following changes to the source based on a MSDN Support Document (http://support.microsoft.com/kb/310083) rather than the CodePlex ones, it solved the problem.
 
Essentially delete the references to the adodb, msdasc, and oledb error. Add the ADODB and Microsoft ActiveX Data Objects 2.7 (I used 6.0 which is the latest) and Microsoft OLEDB Service Component 1.0 Type Library references per the document via the References->COM. Then make the following changes to the PromptForConnectionString method...
 
Before
 
        MSDASC.DataLinks dataLinks = new MSDASC.DataLinksClass();
        ADODB.Connection dialogConnection;

        string generatedConnectionString = string.Empty;
 
        if (currentConnectionString == String.Empty)
        {
            dialogConnection = (ADODB.Connection)dataLinks.PromptNew();
            generatedConnectionString = dialogConnection.ConnectionString.ToString();
        }
 
After
 
        MSDASC.DataLinks dataLinks = new MSDASC.DataLinks();
        ADODB._Connection dialogConnection;

        string generatedConnectionString = string.Empty;
 
        if (currentConnectionString == String.Empty)
        {
            dialogConnection = (ADODB._Connection)dataLinks.PromptNew();
            generatedConnectionString = dialogConnection.ConnectionString.ToString();
        }
 
Now it works without throwing the exception.
 
 
************** Exception Text **************
System.BadImageFormatException: Could not load file or assembly 'Interop.MSDASC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
File name: 'Interop.MSDASC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at DataDictionaryCreator.Main.PromptForConnectionString(String currentConnectionString)
at DataDictionaryCreator.Main.SetConnectionString()
at DataDictionaryCreator.Main.btnSetConnectionString_Click(Object sender, EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
 
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
 
 
 
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)

CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll

System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll

DataDictionaryCreator
Assembly Version: 1.2.0.0
Win32 Version: 1.2.0.0

CodeBase: file:///C:/Users/schletterc.TECHNOLIGENCE/AppData/Local/Apps/2.0/WV060HEX.70K/VB51NXE9.MWK/data..tion_a163f1f54368f8dc_0001.0003_b6a32ed07225a7ff/DataDictionaryCreator.exe

System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll

System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll

Accessibility
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll

System.Deployment
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Deployment/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Deployment.dll

Microsoft.SqlServer.Smo
Assembly Version: 10.0.0.0
Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1539 )

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.Smo/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.Smo.dll

Microsoft.SqlServer.Management.Sdk.Sfc
Assembly Version: 10.0.0.0
Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1539 )

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.Management.Sdk.Sfc/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.Management.Sdk.Sfc.dll

Microsoft.SqlServer.ConnectionInfo
Assembly Version: 10.0.0.0
Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1539 )

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.ConnectionInfo/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.ConnectionInfo.dll

Microsoft.SqlServer.Dmf
Assembly Version: 10.0.0.0
Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1539 )

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.Dmf/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.Dmf.dll

System.Data
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll

System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll

rcnyezs0
Assembly Version: 1.2.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll

Microsoft.SqlServer.SqlClrProvider
Assembly Version: 10.0.0.0
Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1539 )

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.SqlClrProvider/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.SqlClrProvider.dll

System.Transactions
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll

System.EnterpriseServices
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll

System.Security
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Security/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Security.dll

 
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
 
For example:
 
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
 
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

comments

JezzaT wrote Oct 2, 2010 at 10:08 AM

I too get this problem running PromptForConnectionString under 64bit OS - My fix was to simply compile Data Dictionary Creator for x86 platform rather than 'Any CPU'.

JezzaT wrote Jun 1, 2011 at 9:44 PM

A better option than DataLinks might be to use the Microsoft.Data.ConnectionUI.DataConnectionDialog
http://blogs.msdn.com/b/vsdata/archive/2010/02/02/data-connection-dialog-source-code-is-released-on-code-gallery.aspx

and it's even on nuget: http://nuget.org/List/Packages/DataConnectionDialog

fbrustolin wrote Sep 2, 2011 at 6:18 PM

I also changed the destination plataform to x86 as JezzaT suggested and it worked fine.

ClaytonHoyt wrote Jul 30, 2012 at 4:47 PM

To get mine to work, I had to do this a little differently. I am on Win 7 64bit using VS 2010. I had to only add
ActiveX Data Objects 2.7, Microsoft OLEDB Service Component 1.0 Type Library and for some odd reason Microsoft.CSharp. I also converted to x84 build. After this is worked.

websitetec wrote Nov 8, 2013 at 2:03 PM

I didn't have to use the _Connection interface to get mine working, I just had to change DataLinksClass to DataLinks. The rest Was the same. I used the Microsoft ActiveX Data Objects 6.1 and Microsoft OLEDB Service Component 1.0 Type Library references and I also had a problem with the Sql Server SMO objects. The ones in the project were v10 and I have Sql Server 2008 R2 client tools (v11) so I removed the 4 SMO references and added the V11 references and everything worked correctly. Also I had to uncheck the "Sign the ClickOnce manifests" setting in the project properties to get it to compile since the cert is password protected. So to recap, I changed the references above, unchecked the Sign manifests, and changed the following line of code in the MainForm.cs:

Line 573 changed from:
        MSDASC.DataLinks dataLinks = new MSDASC.DataLinksClass();
changed to:
        MSDASC.DataLinks dataLinks = new MSDASC.DataLinks();
Thanks for the post, this will help me get my DB documented properly!

Now if I can only find a way to pull all of the comment work I did in Viso 2010 out into a spreadsheet or xml so I can get it into this app! I guess it time to start googlesearching.

(windows 7 x64, SqlServer SDK 2008 R2, VS 2013)