-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Description
When run the 3rd party application with the latest .NET 10 build, it was no response to open folder. After investigation, we discovered this error: System.InvalidCastException: Unable to cast object of type 'System.__ComObject' to type 'Windows.Win32.UI.Shell.IShellView'.
Reproduction Steps
App Repro Steps:
- Open "WinQuickLookApp\WinQuickLook.App.runtimeconfig.json" file .
2.Change the "WinQuickLook.App.runtimeconfig.json" file to let the app run against with
dotnet-sdk-10.0.100-alpha.1.25057.15.
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "10.0.0-alpha.1.25052.4"
},
{
"name": "Microsoft.WindowsDesktop.App",
"version": "10.0.0-alpha.1.25056.2"
}
],
- Run the ”WinQuickLook\App\WinQuickLook\WinQuickLook.App.exe”.
- Open the folder "WinQuickLook\AdditionFiles\WinQuickLook"
- Choose the “Test” folder.
- Press a space-key.
Expected Result:
Pop up window.
Actual Result:
No window show.
Minimal Repro steps (Demo attached: WpfAppDemo.zip):
- Create a default 8.0 WPF project.
- Add the following code in WpfAppDemo.csproj.
<Platform>x64</Platform>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
- Install package Microsoft.Windows.CsWin32 0.3.106.
- Add the following code in Mainwindow.xaml.cs.
using System.Windows;
using Windows.Win32;
using Windows.Win32.UI.Shell;
using IServiceProvider = Windows.Win32.System.Com.IServiceProvider;
namespace WpfAppDemo
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
var shellWindows = (IShellWindows)new ShellWindows();
shellWindows.get_Count(out var count);
for (var i = 0; i < count; i++)
{
shellWindows.Item(i, out IWebBrowserApp webBrowserApp);
webBrowserApp.get_HWND(out var hwnd);
var serviceProvider = (IServiceProvider)webBrowserApp;
serviceProvider.QueryService(PInvoke.SID_STopLevelBrowser, out IShellBrowser shellBrowser);
shellBrowser.QueryActiveShellView(out var shellView);
}
}
}
}- Copy all file from attachment to project.
- Build the project.
- Change the runtime.config file to let the app run against with dotnet-sdk-10.0.100-alpha.1.25057.15:
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "10.0.0-alpha.1.25052.4"
},
{
"name": "Microsoft.WindowsDesktop.App",
"version": "10.0.0-alpha.1.25056.2"
}
],
- Launch the app.
Expected behavior
Launch successfully.
Actual behavior
Launch failed with error: System.InvalidCastException: Unable to cast object of type 'System.__ComObject' to type 'Windows.Win32.UI.Shell.IShellView'.
Regression?
Yes
Verify Scenarios:
1). Windows 10 22H2 AMD64 + dotnet-sdk-9.0.102: Pass
2). Windows 10 22H2 AMD64 + dotnet-sdk-10.0.100-alpha.1.25057.15: Fail
Known Workarounds
No response
Impact
No response
Configuration
Application Name: WinQuickLook
OS: Windows 10 22H2
CPU: X64
.NET Build Number: dotnet-sdk-10.0.100-alpha.1.25057.15
App & Source Location checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2340552
Github Link: https://github.com/shibayan/WinQuickLook
Dotnet info:
.NET SDK:
Version: 10.0.100-alpha.1.25057.15
Commit: 39da6dde11
Workload version: 10.0.100-manifests.a166a9cf
MSBuild version: 17.14.0-preview-25056-07+8d395fd27
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.100-alpha.1.25057.15\
Host:
Version: 10.0.0-alpha.1.25052.4
Architecture: x64
Commit: efdd299533
.NET SDKs installed:
10.0.100-alpha.1.25057.15 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 10.0.0-alpha.2.25056.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 10.0.0-alpha.1.25052.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 10.0.0-alpha.1.25056.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other information
@dotnet-actwx-bot @dotnet/compat
Metadata
Metadata
Assignees
Labels
Type
Projects
Status