dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.41k stars 984 forks source link

DragDrop registration did not succeed in Designer #6959

Closed kant2002 closed 2 years ago

kant2002 commented 2 years ago

Environment

Version 17.2.0 Preview 2.1

.NET version

7.0 Preview 4

Did this work in a previous version of Visual Studio and/or previous .NET release?

Actually have no idea, I know that designer is flacky.

Issue description

Designer seems to be running with disabled COM interop and some love from Winforms needed.

On the opening form with project WinFormsApp6953.zip

following screen for designer displayed image

Steps to reproduce

  1. Create new WinForms project
  2. Set <TargetFramework>net7.0-windows</TargetFramework>

Diagnostics

No response

RussKie commented 2 years ago

I tried your sample in 17.2.0 Preview 3.0, and it appears to "works on my machine"....

The error message suggests you have build-in COM disabled via a feature switch, though I couldn't readily find the switch via the provided link. @agocke @lakshanf would you know what the feature switch is, or where it is doc'ed? Thanks

kant2002 commented 2 years ago

BuiltInComInteropSupport is the MSBuild switch, or <RuntimeHostConfigurationOption Include="System.Runtime.InteropServices.BuiltInComInterop.IsSupported" Value="false" /> runtime host configuration.

I play a bit with code, and Yes. I cheat a bit. Add following lines

<PublishTrimmed>true</PublishTrimmed>
<_SuppressWinFormsTrimError>true</_SuppressWinFormsTrimError>

Remove bin and obj and rebuild project. You should see issue with blank Winforms project too.

PublishTrimmed implicitly trigger BuiltInComInteropSupport if I remember correctly.

kant2002 commented 2 years ago

After my CCW changes lands, issue disappear in latest preview.