Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.


Go Back   Vista Forums > Misc Newsgroups > PowerShell

RB

Vista - 64-bit PowerShell won't load ADODB type library

Reply
 
08-20-2009   #1
Chuck Heatherly


 

64-bit PowerShell won't load ADODB type library


This code fragment:

$conn = New-Object -ComObject ADODB.Connection
[Convert]::ToInt32([ADODB.ObjectStateEnum]::adStateClosed)

produces the result "0" when run from a 32-bit PowerShell prompt on an x64 PC. However, it
gives this error when run from a 64-bit PowerShell prompt:

Unable to find type [ADODB.ObjectStateEnum]: make sure that the assembly containing this
type is loaded.
At line:2 char:43
+ [Convert]::ToInt32([ADODB.ObjectStateEnum] <<<< ::adStateClosed)
+ CategoryInfo : InvalidOperation: (ADODB.ObjectStateEnum:String) [],
RuntimeException
+ FullyQualifiedErrorId : TypeNotFound

Why? I tested on a Win7 machine with PowerShell 2.0 RTM.

(And yes, I am meaning to use classic ADO and not ADO.NET.)

Thanks,
Chuck

My System SpecsSystem Spec
08-20-2009   #2
Alex K. Angelopoulos


 

Re: 64-bit PowerShell won't load ADODB type library

Chuck, you appear to be using ADODB.ObjectStateEnum from a .NET wrapper
generated for the ADO libraries, based on how you use it. It is _not_
automatically loaded into either 32-bit or 64-bit PowerShell for me.

In any case, it shouldn't matter when using a COM object. The various states
are well-known constant values, and you can just use them directly within
PS. Here's the full set:

$adStateClosed = 0
$adStateOpen = 1
$adStateConnecting = 2
$adStateExecuting = 4
$adStateFetching = 8


Out of curiosity, why _are_ you trying to convert that constant to an int32
value?

"Chuck Heatherly" <chuck.heatherly@xxxxxx> wrote in message
news:fokq851ibchtbkhue8kvhadqr4q2di82sj@xxxxxx
Quote:

>
> This code fragment:
>
> $conn = New-Object -ComObject ADODB.Connection
> [Convert]::ToInt32([ADODB.ObjectStateEnum]::adStateClosed)
>
> produces the result "0" when run from a 32-bit PowerShell prompt on an x64
> PC. However, it
> gives this error when run from a 64-bit PowerShell prompt:
>
> Unable to find type [ADODB.ObjectStateEnum]: make sure that the assembly
> containing this
> type is loaded.
> At line:2 char:43
> + [Convert]::ToInt32([ADODB.ObjectStateEnum] <<<< ::adStateClosed)
> + CategoryInfo : InvalidOperation:
> (ADODB.ObjectStateEnum:String) [],
> RuntimeException
> + FullyQualifiedErrorId : TypeNotFound
>
> Why? I tested on a Win7 machine with PowerShell 2.0 RTM.
>
> (And yes, I am meaning to use classic ADO and not ADO.NET.)
>
> Thanks,
> Chuck
My System SpecsSystem Spec
08-20-2009   #3
Chuck Heatherly


 

Re: 64-bit PowerShell won't load ADODB type library

Alex,

For some reason, the primary interop assembly for the ADODB dll seems to be in the 32-bit
GAC but not the 64-bit one, on my machine.

I edited my profile and added a statement to load the .NET wrapper manually, this has
fixed my problem.

The sample code was just that, a sample. I did not intend for you to think it was a real
program that needed to be critiqued for its logic. I merely wanted to show the behavior.

Chuck

On Thu, 20 Aug 2009 10:36:23 -0400, "Alex K. Angelopoulos"
<alex.k.angelopoulos@xxxxxx> wrote:
Quote:

>Chuck, you appear to be using ADODB.ObjectStateEnum from a .NET wrapper
>generated for the ADO libraries, based on how you use it. It is _not_
>automatically loaded into either 32-bit or 64-bit PowerShell for me.
>
>In any case, it shouldn't matter when using a COM object. The various states
>are well-known constant values, and you can just use them directly within
>PS. Here's the full set:
>
>$adStateClosed = 0
>$adStateOpen = 1
>$adStateConnecting = 2
>$adStateExecuting = 4
>$adStateFetching = 8
>
>
>Out of curiosity, why _are_ you trying to convert that constant to an int32
>value?
>
>"Chuck Heatherly" <chuck.heatherly@xxxxxx> wrote in message
>news:fokq851ibchtbkhue8kvhadqr4q2di82sj@xxxxxx
Quote:

>>
>> This code fragment:
>>
>> $conn = New-Object -ComObject ADODB.Connection
>> [Convert]::ToInt32([ADODB.ObjectStateEnum]::adStateClosed)
>>
>> produces the result "0" when run from a 32-bit PowerShell prompt on an x64
>> PC. However, it
>> gives this error when run from a 64-bit PowerShell prompt:
>>
>> Unable to find type [ADODB.ObjectStateEnum]: make sure that the assembly
>> containing this
>> type is loaded.
>> At line:2 char:43
>> + [Convert]::ToInt32([ADODB.ObjectStateEnum] <<<< ::adStateClosed)
>> + CategoryInfo : InvalidOperation:
>> (ADODB.ObjectStateEnum:String) [],
>> RuntimeException
>> + FullyQualifiedErrorId : TypeNotFound
>>
>> Why? I tested on a Win7 machine with PowerShell 2.0 RTM.
>>
>> (And yes, I am meaning to use classic ADO and not ADO.NET.)
>>
>> Thanks,
>> Chuck
My System SpecsSystem Spec
Reply

RB


Thread Tools


Similar Threads for: 64-bit PowerShell won't load ADODB type library
Thread Forum
Re: Unable to cast COM object of type 'ADODB.RecordsetClass' to class type 'System.Object[]' .NET General
Difficulties using ADODB.recordset in powershell PowerShell
Error loading type library Vista security
Can't load library from memory Vista installation & setup
Powershell 32 vs. 64 when using ADODB PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd