Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

COM objects are not enumerating properly #3775

Copy link
Copy link
@jpsnover

Description

@jpsnover
Issue body actions

Repro

Open a File Explorer window first if you find $w.Count is 0

PSv6> $s = New-Object -ComObject "Shell.Application"
PSv6> $w = $s.Windows()
PSv6> $w.Count
1
PSv6> $w  ## dump $w, and powershell should enumerate $w to unwrap the collection

Expected Behavior

$w is unwrapped and the contained items are dumpped out (PSv5 behavior)

Application          : System.__ComObject
Parent               : System.__ComObject
Container            :
Document             : System.__ComObject
TopLevelContainer    : True
Type                 :
Left                 : -32000
Top                  : -32000
Width                : 160
Height               : 28
LocationName         : 6.0.0-beta1
LocationURL          : file:///D:/PowerShell/6.0.0-beta1
Busy                 : False
Name                 : File Explorer
HWND                 : 923136
FullName             : C:\WINDOWS\Explorer.EXE
Path                 : C:\WINDOWS\
Visible              : True
StatusBar            : False
StatusText           :
ToolBar              : 1
MenuBar              : False
FullScreen           : False
ReadyState           : 4
Offline              : False
Silent               : False
RegisterAsBrowser    : False
RegisterAsDropTarget : True
TheaterMode          : False
AddressBar           : True
Resizable            : True

Actual Behavior

Count
-----
    2

Environment

PSv6> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.0-beta
PSEdition                      Core
BuildVersion                   3.0.0.0
CLRVersion
GitCommitId                    v6.0.0-beta.1
OS                             Microsoft Windows 10.0.15063
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Additional Observation

The problem appears to be this:

PSv6>  $w._NewEnum()
An error occurred while enumerating through a collection: Could not load type 'System.Runtime.InteropServices.ComTypes.IEnumerator' from assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=7cec85d7bea7798e'..
At line:1 char:2
+  $w._NewEnum()
+  ~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.__ComObject:__ComObject) [], RuntimeException
    + FullyQualifiedErrorId : BadEnumeration
Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

Blockedblocked on something external to this repoblocked on something external to this repoBreaking-Changebreaking change that may affect usersbreaking change that may affect usersIssue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.