Powershell v2 :: Download COM Interop COM Library

I have this DataLink DLL on my system - Interop.MSDASC.dll I am trying to load the same from Powershell as this -

[Reflection.Assembly]::LoadFile("C:\Interop.MSDASC.dll") | out-null

But, I get the following error -

Exception calling "LoadFile" with "1" argument(s): "Could not load file or assembly 'Interop.MSDASC.dll' or one of its dependencies.  is not a 
valid Win32 application. (Exception from HRESULT: 0x800700C1)"
At line:1 char:32
+ [Reflection.Assembly]::LoadFile <<<< ("C:\Interop.MSDASC.dll") | out-null
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

How to load this correctly?

+3
source share
2 answers

This is a 32-bit COM object, so you must load it from a 32-bit PowerShell instance. To do this, on a 64-bit version of Windows, you can run powershell.exe or powershell_ISE.exe in this folder:% SYSTEMROOT% \ SysWOW64 \ WindowsPowerShell \ v1.0

And this is the full code:

[Reflection.Assembly]::LoadFile("C:\Interop.MSDASC.dll") 
$dataLinkInstance = new-object MSDASC.DataLinksClass
$dataLinkInstance.WriteStringToStorage("C:\\FrmPowershell.udl", "Provider=SQLOLEDB.1;", 2)
+9
source

http://datadictionary.codeplex.com/ , , :

 [System.Reflection.Assembly]::LoadFile( "c:\Program Files\DataDictionaryCreator\Interop.MSDASC.dll")

GAC    Version        Location
---    -------        --------
False  v2.0.50727     c:\Program Files\DataDictionaryCreator\Interop.MSDASC.dll

, x64? , http://datadictionary.codeplex.com/workitem/28807

+3

All Articles