That can be done with Assembly.Load method, but you have to create the objects using reflection from the loaded assembly, and late binding (Objects). Here is an example of use where ADOX and ADODB is used to create a new Excel book:
Sub newexcel()
Dim ax, adb As System.Reflection.Assembly
ax = Reflection.Assembly.Load(getResource("WindowsApplication1.Interop.ADOX.dll"))
adb = Reflection.Assembly.Load(getResource("WindowsApplication1.Interop.ADODB.dll"))
Dim cnn As Object = adb.CreateInstance("ADODB.ConnectionClass") 'ADODB.Connection
Dim cat As Object = ax.CreateInstance("ADOX.CatalogClass") 'ADOX.Catalog
Dim tbl As Object = ax.CreateInstance("ADOX.TableClass") 'ADOX.Table
cnn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "C:\Test.XLS" & ";Extended Properties=Excel 8.0")
cat.ActiveConnection = cnn
tbl.Name = "MyContacts"
tbl.ParentCatalog = cat
tbl.Columns.Append("x")
cat.Tables.Append(tbl)
cnn.Close()
End Sub
Function getResource(ByVal name As String) As Byte()
Dim br As New IO.BinaryReader(Me.GetType.Assembly.GetManifestResourceStream(name))
Dim bytes() As Byte = br.ReadBytes(br.BaseStream.Length)
br.Close()
Return bytes
End Function
Some explanations: The interop files is here added as embedded resources, filename f.ex "Interop.ADOX.dll" and is qualified when reading the resource with the local assembly namespace ("WindowsApplication1" here). I found that the COM class type names were appended "Class" when loaded from assembly, like "ADODB.Connection" became "ADODB.ConnectionClass".