dotnet / project-system

The .NET Project System for Visual Studio
MIT License
967 stars 386 forks source link

Get an error when you attempt to launch Windows Forms designer for a VB project #5351

Open davkean opened 5 years ago

davkean commented 5 years ago

Visual Studio Version: Version 16.3.0 Preview 3.0 [29221.207.master]

Summary: Cannot launch the designer for Windows Forms for VB projects. The equivalent project for C# works.

Steps to Reproduce:

  1. File -> New -> Visual Basic Windows Forms (.NET Core)
  2. Open project file and change netcoreapp3.0 to net472
  3. Double-click on Form1.cs

Expected Behavior: Designer to open

Actual Behavior:

image


at  Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse..ctor(IDesignTimeAssemblyLoader  assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution,  IVsSmartOpenScope dispenser)at  Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.GetUniverse(IDesignTimeAssemblyLoader  assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution,  IVsSmartOpenScope dispenser)at  Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider..ctor(IVsDesignTimeAssemblyResolution  assemblyResolution, IDesignTimeAssemblyLoader assemblyLoader,  TypeDescriptionProvider parentProvider, IVsSmartOpenScope openScope)at  Microsoft.VisualStudio.Design.VsTargetFrameworkProviderService.get_TargetFrameworkProvider()at  Microsoft.VisualStudio.Design.VsTargetFrameworkProviderService.GetProvider(Type  type)at  System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetType(String  typeName)at  System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.GetType(String  typeName)at  System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager  manager, CodeTypeDeclaration declaration)at  System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager  manager)at  Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager  serializationManager)at  System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost  host) | at  Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse..ctor(IDesignTimeAssemblyLoader  assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution,  IVsSmartOpenScope dispenser)at  Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.GetUniverse(IDesignTimeAssemblyLoader  assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution,  IVsSmartOpenScope dispenser)at  Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider..ctor(IVsDesignTimeAssemblyResolution  assemblyResolution, IDesignTimeAssemblyLoader assemblyLoader,  TypeDescriptionProvider parentProvider, IVsSmartOpenScope openScope)at  Microsoft.VisualStudio.Design.VsTargetFrameworkProviderService.get_TargetFrameworkProvider()at  Microsoft.VisualStudio.Design.VsTargetFrameworkProviderService.GetProvider(Type  type)at  System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetType(String  typeName)at  System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.GetType(String  typeName)at  System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager  manager, CodeTypeDeclaration declaration)at  System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager  manager)at  Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager  serializationManager)at  System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost  host) | at  Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse..ctor(IDesignTimeAssemblyLoader  assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution,  IVsSmartOpenScope dispenser)at  Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.GetUniverse(IDesignTimeAssemblyLoader  assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution,  IVsSmartOpenScope dispenser)at  Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider..ctor(IVsDesignTimeAssemblyResolution  assemblyResolution, IDesignTimeAssemblyLoader assemblyLoader,  TypeDescriptionProvider parentProvider, IVsSmartOpenScope openScope)at  Microsoft.VisualStudio.Design.VsTargetFrameworkProviderService.get_TargetFrameworkProvider()at  Microsoft.VisualStudio.Design.VsTargetFrameworkProviderService.GetProvider(Type  type)at  System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetType(String  typeName)at  System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.GetType(String  typeName)at  System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager  manager, CodeTypeDeclaration declaration)at  System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager  manager)at  Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager  serializationManager)at  System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost  host)
-- | -- | --
at  Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse..ctor(IDesignTimeAssemblyLoader  assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution,  IVsSmartOpenScope dispenser)at  Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.GetUniverse(IDesignTimeAssemblyLoader  assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution,  IVsSmartOpenScope dispenser)at  Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider..ctor(IVsDesignTimeAssemblyResolution  assemblyResolution, IDesignTimeAssemblyLoader assemblyLoader,  TypeDescriptionProvider parentProvider, IVsSmartOpenScope openScope)at  Microsoft.VisualStudio.Design.VsTargetFrameworkProviderService.get_TargetFrameworkProvider()at  Microsoft.VisualStudio.Design.VsTargetFrameworkProviderService.GetProvider(Type  type)at  System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetType(String  typeName)at  System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.GetType(String  typeName)at  System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager  manager, CodeTypeDeclaration declaration)at  System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager  manager)at  Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager  serializationManager)at  System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost  host) | at  Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse..ctor(IDesignTimeAssemblyLoader  assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution,  IVsSmartOpenScope dispenser)at  Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.GetUniverse(IDesignTimeAssemblyLoader  assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution,  IVsSmartOpenScope dispenser)at  Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider..ctor(IVsDesignTimeAssemblyResolution  assemblyResolution, IDesignTimeAssemblyLoader assemblyLoader,  TypeDescriptionProvider parentProvider, IVsSmartOpenScope openScope)at  Microsoft.VisualStudio.Design.VsTargetFrameworkProviderService.get_TargetFrameworkProvider()at  Microsoft.VisualStudio.Design.VsTargetFrameworkProviderService.GetProvider(Type  type)at  System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetType(String  typeName)at  System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.GetType(String  typeName)at  System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager  manager, CodeTypeDeclaration declaration)at  System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager  manager)at  Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager  serializationManager)at  System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost  host)
at  Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse..ctor(IDesignTimeAssemblyLoader  assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution,  IVsSmartOpenScope dispenser)at  Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.GetUniverse(IDesignTimeAssemblyLoader  assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution,  IVsSmartOpenScope dispenser)at  Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider..ctor(IVsDesignTimeAssemblyResolution  assemblyResolution, IDesignTimeAssemblyLoader assemblyLoader,  TypeDescriptionProvider parentProvider, IVsSmartOpenScope openScope)at  Microsoft.VisualStudio.Design.VsTargetFrameworkProviderService.get_TargetFrameworkProvider()at  Microsoft.VisualStudio.Design.VsTargetFrameworkProviderService.GetProvider(Type  type)at  System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetType(String  typeName)at  System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.GetType(String  typeName)at  System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager  manager, CodeTypeDeclaration declaration)at  System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager  manager)at  Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager  serializationManager)at  System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost  host)
davkean commented 5 years ago

Set a breakpoint in https://github.com/dotnet/project-system/blob/master/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/References/DesignTimeAssemblyResolution.cs, this should be returning "mscorlib".

davidwengier commented 5 years ago

Confirmed that mscorlib is not coming through from CPS (project.References.OfType<Reference3>()) for VB projects, only C#.

davkean commented 5 years ago

Grab a binlog of the ResolveAssemblyReferences call that shows it missing, it might be an SDK bug.

davkean commented 5 years ago

Oh, thinking about this a little more - it might not be an SDK bug, it might be our bug. There's a built-in assumption that all references show up in list of references, but VB is probably a little different around this. Legacy doesn't walk references, but goes through the RAR task itself to resolve mscorlib.

davidwengier commented 5 years ago

Looking at the design time build, RAR doesn't include mscorlib.dll for VB projects. CPS does use the RAR output for references, though it doesn't block on them obviously.

I'm not sure what the fix is here. I can include mscorlib.dll as a reference in a VB design time build, but then we need to block the designer. I also can't see why C# has the reference there during evaluation, but I'm probably not looking in the right spot.

davkean commented 5 years ago

VB build is different, I think IRC it picks it up from the sdk path that is passed to it. We do not want behavior differences between design-time builds and regular builds for inputs into the compiler so adding it during design-time builds will result in that.

The designer is blocked on a design build anyway (that's what the results of the references are from), so that's not the problem.

This requires thought, feel free to throw it to me, I wrote the original one and it needs to be updated to handle this similar to legacy.

davidwengier commented 5 years ago

The designer is blocked on a design build anyway (that's what the results of the references are from), so that's not the problem.

On my local machine if I add <_ExplicitReference Include="$(FrameworkPathOverride)\mscorlib.dll" /> to DesignTime.targets, then opening the designer works if I wait for the design time build to finish, but if I open it early I still get the error. Is that not because the designer isn't blocked on the design time build?

davkean commented 5 years ago

Yes that's what operation progress is solving.

Crono1981 commented 4 years ago

I'm having the issue right now with Visual Studio 16.4, on a side project that is not an EXE but rather a controls and forms library.

@davidwengier workaround with _ExplicitReference seems to do the trick, but I don't feel confident going forward with migrating about a hundred legacy VB projects to the new SDK with it.

Can anyone explain what's going on with VB.NET support in MS products right now? Because from the look of it - and I don't mean that as a rant -, it really does feel like it's being slowly put aside... knowing that it "officially" is would at least help me making some though decisions...

ehasis commented 2 years ago

I'm with Visual Studio 2022 (17.2.1) and still having this problem (VB only). This is blocking us to move to SDK project in order to begin migration to .NET 6+.

ehasis commented 1 year ago

Any news about this issue? Is still happening with 17.3.5.

ehasis commented 1 year ago

Still not working with 17.5.1 (as is tagged for 7.6). I didn't get how exactly I should do with <_ExplicitReference Include="$(FrameworkPathOverride)\mscorlib.dll" />, can you explain better how to do with this workaroud?

dpvreony commented 1 year ago

workaround that works for me is to add the following in the vbproj

    <Target Name="AddAdditionalReferences" BeforeTargets="ResolveAssemblyReferences">
        <ItemGroup Condition=" '$(NoStdLib)' != 'true' ">
            <_ExplicitReference Include="$(FrameworkPathOverride)\mscorlib.dll" />
        </ItemGroup>
    </Target>
Pao-lino commented 10 months ago

I had the same problem on net48, solved with the workaround provided by dpvreony. https://github.com/dotnet/project-system/issues/5351#issuecomment-1479499990

I've noticed that the problem does not occour on net481. I didn't understand why I had this problem on a particular project, while on many others WinForms project I didn't have this issue.

Please fix it. Thanks