We help IT Professionals succeed at work.

Cannot load Interop.MSDASC in VB.net app

I'm trying to add the Data Link Properties window to my app to allow my users to quickly build a connection string to a database (Access, SQL, etc.) without having to know all the data providers for each.  I was following directions found here: http://www.codeguru.com/vb/gen/vb_database/article.php/c5139.  After adding references to my project for ADODB and Microsoft OLE DB Service Component 1.0 Type Library I used the code below to load the Datalink properies form when I click a button.  However, when I try to do the click the button, Visual Studio returns the following error:

"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."

What am I doing wrong.
Imports MSDASC
Imports ADODB

Public Class Form1
	Inherits System.Windows.Forms.Form

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		If Not My.Settings.ConnString Is Nothing Then
			txtConnString.Text = My.Settings.ConnString.ConnectionString
		End If
	End Sub

	Private Sub btnConnString_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnString.Click
		Dim myDataLinkProp As DataLinksClass = New DataLinksClass
		Dim myConnection As ConnectionClass = New ConnectionClass

		If myDataLinkProp.PromptEdit(myConnection) Then txtConnString.Text = myConnection.ConnectionString

	End Sub

	Private Sub SaveConnectionStringToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveConnectionStringToolStripMenuItem.Click
		My.Settings.ConnString.ConnectionString = txtConnString.Text
	End Sub
End Class

Open in new window

Comment
Watch Question

Most Valuable Expert 2012
Top Expert 2008
Commented:
You aren't doing anything wrong.  It sounds like you don't have something working correctly.  You would need to find out what the missing dependency is, which is made easier by a program like Dependency Walker.

Author

Commented:
That helped but hasn't solved my issue.  It pointed to the fact that the DLL has 32 bit DLL file dependencies.  When running the code on my 32 bit virtual machine, it works fine, but when running in on my 64 bit Win 7 primary machine it is throwing this error.  Any ideas how I can fix this?

Author

Commented:
I'm just going to set my app to only compile in x86.  Maybe someday someone will write a .Net version of the Data Link Properties window to replace the old Com version.

Author

Commented:
It pointed me in the right direction.  The best answers are ones that help the end user figure out the problem for them selves.