project-system icon indicating copy to clipboard operation
project-system copied to clipboard

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

Open davkean opened this issue 6 years ago • 15 comments

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 avatar Aug 22 '19 15:08 davkean

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".

davkean avatar Aug 22 '19 15:08 davkean

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

davidwengier avatar Aug 22 '19 23:08 davidwengier

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

davkean avatar Aug 23 '19 01:08 davkean

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.

davkean avatar Aug 23 '19 01:08 davkean

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.

davidwengier avatar Aug 23 '19 05:08 davidwengier

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.

davkean avatar Aug 23 '19 05:08 davkean

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?

davidwengier avatar Aug 23 '19 05:08 davidwengier

Yes that's what operation progress is solving.

davkean avatar Aug 23 '19 05:08 davkean

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...

dav-tb avatar Dec 05 '19 20:12 dav-tb

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 avatar May 19 '22 14:05 ehasis

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

ehasis avatar Oct 15 '22 14:10 ehasis

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?

ehasis avatar Mar 04 '23 23:03 ehasis

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>

dpvreony avatar Mar 22 '23 12:03 dpvreony

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

Pao-lino avatar Nov 17 '23 14:11 Pao-lino