-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Description
On a PowerShell build with .NET 6 Preview 7, when a new instance of a COM object is done, we get an error: Constructor on type 'System.__ComObject' not found. which is System.MissingMethodException
Gist for sample code to repro the error:
Configuration
.NET 6 Preview 7 SDK on Windows 10 x64.
Regression?
Yes, from .NET 6 Preview 6
Other information
Repro for the issue is on PowerShell built against .NET 6 Preview 7 SDK.
PS C:> $fileSystem = New-Object -ComObject scripting.filesystemobject
New-Object: Constructor on type 'System.__ComObject' not found.
PS C:> Get-Error
Exception :
Type : System.MissingMethodException
Message : Constructor on type 'System.__ComObject' not found.
TargetSite :
Name : CreateInstanceImpl
DeclaringType : System.RuntimeType, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
MemberType : Method
Module : System.Private.CoreLib.dll
Source : System.Private.CoreLib
HResult : -2146233069
StackTrace :
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) in System.Private.CoreLib.dll:token 0x60006c6+0x173
at System.Activator.CreateInstance(Type type, Object[] args) in System.Private.CoreLib.dll:token 0x60009e0+0x0
at Microsoft.PowerShell.Commands.NewObjectCommand.SafeCreateInstance(Type t, Object[] args) in D:\PSGit\PowerShell\src\Microsoft.PowerShell.Commands.Utility\commands\utility\New-Object.cs:line 359
CategoryInfo : InvalidOperation: (:) [New-Object], MissingMethodException
FullyQualifiedErrorId : NoPublicCtorMatch,Microsoft.PowerShell.Commands.NewObjectCommand
InvocationInfo :
MyCommand : New-Object
ScriptLineNumber : 1
OffsetInLine : 15
HistoryId : 9
Line : $fileSystem = New-Object -ComObject scripting.filesystemobject
PositionMessage : At line:1 char:15
+ $fileSystem = New-Object -ComObject scripting.filesystemobject
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : New-Object
CommandOrigin : Internal
ScriptStackTrace : at , : line 1