You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add Windows Form does not nest .designer.cs under .cs #1272
Feature-WinFormsFeatures related to bringing up the Windows Forms designer and related features.Parity-Legacy-FeatureMissing features from the legacy project system.Resolution-DuplicateThe bug is a duplicate of another bug in this or another repo.
I hate to complain because of the amazing results you've already had, but six lines feels a bit more verbose than it needs to be. Is something like this possible? (Is SubType needed in the .csproj itself or can that info be cached after examining the contents? Could the nesting be automatic as well?)
Once the designer is opened, the Text property is blank. Usually it would be Form1.
Once the form is edited in the designer, Form1.resx shows up and Form1.designer.cs nests under that. Usually they'd nest as siblings with the parent Form1.cs.
Correction: This is not an absolute showstopper, just very tedious to work around.
Every time the form is edited in the designer, Form1.designer.cs gets replaced by the codegen for Form1.resx. This loses the partial modifier so the code does not compile, and moves InitializeComponent and all the field declarations into Form1.cs which is less than ideal.
Every time, I have to manually remove the internal modifier and add the partial modifier to Form1.designer.cs and delete the constructor.
I don't have the option to not use the resx. It gets created just by me setting a form property in the designer and saving.
I'm pretty sure that the fact that the form is a partial class with the RESX code will be a major problem at some point- for example, if I don't want a parameterless constructor.
I tried deleting the .resx and the resx-generated designer file and now the designer will not open. Two errors:
NotImplementedException, call stack:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at Microsoft.VisualStudio.Design.Serialization.LicenseService.GetLicenseDocData(FileAccess access)
at Microsoft.VisualStudio.Design.Serialization.LicenseService.FillLicensedTypes()
at Microsoft.VisualStudio.Design.Serialization.LicenseService.get_LicensedTypes()
at Microsoft.VisualStudio.Design.Serialization.LicenseService.OnComponentAdded(Object sender, ComponentEventArgs e)
at System.ComponentModel.Design.ComponentEventHandler.Invoke(Object sender, ComponentEventArgs e)
at System.ComponentModel.Design.DesignerHost.AddToContainerPostProcess(IComponent component, String name, IContainer containerToAddTo)
at System.ComponentModel.Design.DesignerHost.PerformAdd(IComponent component, String name)
at System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.CreateComponent(Type componentType, String name)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeInstance(IDesignerSerializationManager manager, Type type, Object[] parameters, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.ComponentCodeDomSerializer.DeserializeInstance(IDesignerSerializationManager manager, Type type, Object[] parameters, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
at System.ComponentModel.Design.Serialization.CodeDomSerializer.DeserializeStatementToInstance(IDesignerSerializationManager manager, CodeStatement statement)
at System.ComponentModel.Design.Serialization.CodeDomSerializer.Deserialize(IDesignerSerializationManager manager, Object codeObject)
at System.Windows.Forms.Design.ControlCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, Object codeObject)
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.DeserializeName(IDesignerSerializationManager manager, String name, CodeStatementCollection statements)
and "The variable 'buttonEdit1' is either undeclared or was never assigned." which takes me to the code, wherein buttonEdit1 is most certainly both declared and assigned.
The point of this exercise was to be able to see if the new .csproj offers deliverance from the madness that is licenses.licx, but I wasn't able to get that far. I'm guessing the NotImplementedException above, plus the message boxes I was getting earlier while moving controls around with the same NotImplementedException message, are indicative of a license system failure.
Here's what I'm hoping will eventually be the case:
I can migrate all built-in csproj types to the new project system. WinForms, WPF, anything. This was the main justification for the decision to unify everything under .csproj and I'm still looking forward to the list of benefits across the board.
No more listing .cs files and the resulting merge conflicts and careful source control diffing on each checkin!
No more licenses.licx appearing in the .csproj! It's fine existing locally (even though it's truly pointless and should be cached outside of the source code), but the file itself is filtered from source control because of the inevitable thrashing that happens and the inevitable version errors on both dev machines and the build server. The last remaining piece of the puzzle is to keep it from appearing in the .csproj at all, because it's hard to notice and catch that before accidentally checking in the .csproj and having the build server choke on the missing file.
As you noticed, we don't support WinForms yet. For the time being we're focused on .NET Core and only build and deploy for .NET Framework. The designers, etc do not/will not work until post VS 2017 RTM.
I think it's helpful to get issues filed on these and let's get them tagged so that we can understand what it takes to bring up WinForms (it's a going to be peeling of the onion).
The sub type issue is already being tracked here: #997.
As you noticed, we don't support WinForms yet. For the time being we're focused on .NET Core and only build and deploy for .NET Framework. The designers, etc do not/will not work until post VS 2017 RTM.
Understood. My goal is to make these things visible so they happen sooner rather than later, because until there's a strong UI library for Core I'll be using WinForms for a while.
The other issues we are not tracking - would you like to file them or do you want me to?
Doesn't matter to me. They will probably be of more value if you file them since you know what's under the hood.
@damageboy Did you find a solution for this yet? I am currently trying to figure out the exact same issue. I am glad I got it working to conditionally reference System.Windows.Forms whenever it is building for net461... That works but my Designer doesnt show up.
@jnm2 We're bringing up WinForms now - let's use new issues to track each individual issue; bugs we're aware of are being tracked by the WinForms label:
Feature-WinFormsFeatures related to bringing up the Windows Forms designer and related features.
.
The nesting itself is being tracked by #159, and we've implemented for 16.0 using rules of legacy but without DependentUpon. We'll respect DependentUpon if its present, otherwise, we'll just auto-nest based on existing rules. I'm going to dupe this bug against it.
The point of this exercise was to be able to see if the new .csproj offers deliverance from the madness that is licenses.licx, but I wasn't able to get that far. I'm guessing the NotImplementedException above, plus the message boxes I was getting earlier while moving controls around with the same NotImplementedException message, are indicative of a license system failure.
Here's what I'm hoping will eventually be the case:
I can migrate all built-in csproj types to the new project system. WinForms, WPF, anything. This was the main justification for the decision to unify everything under .csproj and I'm still looking forward to the list of benefits across the board.
No more listing .cs files and the resulting merge conflicts and careful source control diffing on each checkin!
No more licenses.licx appearing in the .csproj! It's fine existing locally (even though it's truly pointless and should be cached outside of the source code), but the file itself is filtered from source control because of the inevitable thrashing that happens and the inevitable version errors on both dev machines and the build server. The last remaining piece of the puzzle is to keep it from appearing in the .csproj at all, because it's hard to notice and catch that before accidentally checking in the .csproj and having the build server choke on the missing file.
I'm facing the same issue with Active Report, do we have any idea to bring back the designer?
Correction: This is not an absolute showstopper, just very tedious to work around.
Every time the form is edited in the designer, Form1.designer.cs gets replaced by the codegen for Form1.resx. This loses the partial modifier so the code does not compile, and moves InitializeComponent and all the field declarations into Form1.cs which is less than ideal.
Every time, I have to manually remove the internal modifier and add the partial modifier to Form1.designer.cs and delete the constructor.
I don't have the option to not use the resx. It gets created just by me setting a form property in the designer and saving.
I'm pretty sure that the fact that the form is a partial class with the RESX code will be a major problem at some point- for example, if I don't want a parameterless constructor.
I tried deleting the .resx and the resx-generated designer file and now the designer will not open. Two errors:
NotImplementedException, call stack:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at Microsoft.VisualStudio.Design.Serialization.LicenseService.GetLicenseDocData(FileAccess access)
at Microsoft.VisualStudio.Design.Serialization.LicenseService.FillLicensedTypes()
at Microsoft.VisualStudio.Design.Serialization.LicenseService.get_LicensedTypes()
at Microsoft.VisualStudio.Design.Serialization.LicenseService.OnComponentAdded(Object sender, ComponentEventArgs e)
at System.ComponentModel.Design.ComponentEventHandler.Invoke(Object sender, ComponentEventArgs e)
at System.ComponentModel.Design.DesignerHost.AddToContainerPostProcess(IComponent component, String name, IContainer containerToAddTo)
at System.ComponentModel.Design.DesignerHost.PerformAdd(IComponent component, String name)
at System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.CreateComponent(Type componentType, String name)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeInstance(IDesignerSerializationManager manager, Type type, Object[] parameters, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.ComponentCodeDomSerializer.DeserializeInstance(IDesignerSerializationManager manager, Type type, Object[] parameters, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
at System.ComponentModel.Design.Serialization.CodeDomSerializer.DeserializeStatementToInstance(IDesignerSerializationManager manager, CodeStatement statement)
at System.ComponentModel.Design.Serialization.CodeDomSerializer.Deserialize(IDesignerSerializationManager manager, Object codeObject)
at System.Windows.Forms.Design.ControlCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, Object codeObject)
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.DeserializeName(IDesignerSerializationManager manager, String name, CodeStatementCollection statements)
and "The variable 'buttonEdit1' is either undeclared or was never assigned." which takes me to the code, wherein buttonEdit1 is most certainly both declared and assigned.
I just ran into this exact issue when trying to update the project file of a winforms project to the SDK style project (note, I'm only updating the project file, the target framework is still .NET Framework 4.7.2). Forms/UserControls that use vanilla WinForms controls open fine in the Designer, but if I used a licensed control, it fails with the exception mentioned above.
Is there any fix/workaround for this? Or any ETA on when (if ever) it will get fixed?
I found out (not why but) when it happens. It happens as soon as the relative path to your .cs and .resx files has a white space. As soon as there is any white space, the .designer.resx will not move to .resx and stay at .cs.
How to:
Close your project in Visual Studio
Open your project in Windows Explorer
Move all your code files (and anything else, or just your forms) to a sub directory with a white space in the name (e.g. "My Codes")
Open the .csproj of your project in a text editor (e.g. Visual Studio Code) and replace everything of =" with ="\
Save and open your project in Visual Studio again.
Done! You are now able to edit your dialogs in WinForms Designer again without problems.
Feature-WinFormsFeatures related to bringing up the Windows Forms designer and related features.Parity-Legacy-FeatureMissing features from the legacy project system.Resolution-DuplicateThe bug is a duplicate of another bug in this or another repo.
Activity
jnm2 commentedon Jan 20, 2017
I hate to complain because of the amazing results you've already had, but six lines feels a bit more verbose than it needs to be. Is something like this possible? (Is
SubTypeneeded in the .csproj itself or can that info be cached after examining the contents? Could the nesting be automatic as well?)jnm2 commentedon Jan 20, 2017
More differences:
Form1.csis not the Form icon.Form1.Form1.resxshows up andForm1.designer.csnests under that. Usually they'd nest as siblings with the parentForm1.cs.jnm2 commentedon Jan 20, 2017
Correction: This is not an absolute showstopper, just very tedious to work around.
Form1.designer.csgets replaced by the codegen forForm1.resx. This loses thepartialmodifier so the code does not compile, and movesInitializeComponentand all the field declarations intoForm1.cswhich is less than ideal.Every time, I have to manually remove the
internalmodifier and add thepartialmodifier toForm1.designer.csand delete the constructor.I don't have the option to not use the resx. It gets created just by me setting a form property in the designer and saving.
I'm pretty sure that the fact that the form is a partial class with the RESX code will be a major problem at some point- for example, if I don't want a parameterless constructor.
I tried deleting the .resx and the resx-generated designer file and now the designer will not open. Two errors:
NotImplementedException, call stack:
and "The variable 'buttonEdit1' is either undeclared or was never assigned." which takes me to the code, wherein buttonEdit1 is most certainly both declared and assigned.
jnm2 commentedon Jan 20, 2017
The point of this exercise was to be able to see if the new .csproj offers deliverance from the madness that is
licenses.licx, but I wasn't able to get that far. I'm guessing the NotImplementedException above, plus the message boxes I was getting earlier while moving controls around with the same NotImplementedException message, are indicative of a license system failure.Here's what I'm hoping will eventually be the case:
jnm2 commentedon Jan 20, 2017
I was able to confirm that a call to
LicenseManager.Validatein a custom control constructor causes the NotImplementedException.That brings this issue to a total of seven issues. Should I start issues for these or are they closely related enough for your purposes?
davkean commentedon Jan 23, 2017
@jnm2 Hey thanks for trying out these scenarios.
As you noticed, we don't support WinForms yet. For the time being we're focused on .NET Core and only build and deploy for .NET Framework. The designers, etc do not/will not work until post VS 2017 RTM.
I think it's helpful to get issues filed on these and let's get them tagged so that we can understand what it takes to bring up WinForms (it's a going to be peeling of the onion).
The sub type issue is already being tracked here: #997.
The nesting issue is being tracked here: #159.
The other issues we are not tracking - would you like to file them or do you want me to?
jnm2 commentedon Jan 23, 2017
Understood. My goal is to make these things visible so they happen sooner rather than later, because until there's a strong UI library for Core I'll be using WinForms for a while.
Doesn't matter to me. They will probably be of more value if you file them since you know what's under the hood.
PawelTroka commentedon Jun 13, 2017
When it will be done? It's important to me because it is the last thing remaining on my way to new csproj format :)
damageboy commentedon Oct 29, 2017
This is also bugging me.
I'm trying to move entirely into new csproj land, and while most of my stuff will work as is, I have one(!) WinForms app that is holding me back.
Is there anyway, even if undocumented, to make new csproj deal with WinForms projects (while keeping the designer functional)?
jnm2 commentedon Oct 29, 2017
Yes, @onovotny, I've been meaning to ask if you have inside information to swoop in and save the day again?
johmarjac commentedon Feb 15, 2018
@damageboy Did you find a solution for this yet? I am currently trying to figure out the exact same issue. I am glad I got it working to conditionally reference System.Windows.Forms whenever it is building for net461... That works but my Designer doesnt show up.
clairernovotny commentedon Feb 15, 2018
@johmarjac Have you tried using the MSBuild.Sdk.Extras? It adds the proper nesting support.
jnm2 commentedon Feb 15, 2018
@onovotny Does
MSBuild.Sdk.Extrascause the designers to be usable again?8 remaining items
Initial commit of Microsoft.NET.Sdk.WindowsForms project
zapirkon commentedon Jul 21, 2018
For me, when I add new form "test.cs" the csproj will contain:
in order to nest the designer, manually edit the csproj by adding right below it, two new nodes in the same ItemGroup:
now, Shift+F7 works, designer works.
And I did not include MSBuildSdkExtras
damageboy commentedon Jul 26, 2018
But what happens when you change something through the designer?
davkean commentedon Aug 2, 2018
@jnm2 We're bringing up WinForms now - let's use new issues to track each individual issue; bugs we're aware of are being tracked by the WinForms label: Feature-WinFormsFeatures related to bringing up the Windows Forms designer and related features.
.
The nesting itself is being tracked by #159, and we've implemented for 16.0 using rules of legacy but without DependentUpon. We'll respect DependentUpon if its present, otherwise, we'll just auto-nest based on existing rules. I'm going to dupe this bug against it.
toanxyz commentedon Jan 28, 2019
I'm facing the same issue with Active Report, do we have any idea to bring back the designer?
petroemil commentedon May 24, 2019
@jnm2
I just ran into this exact issue when trying to update the project file of a winforms project to the SDK style project (note, I'm only updating the project file, the target framework is still .NET Framework 4.7.2). Forms/UserControls that use vanilla WinForms controls open fine in the Designer, but if I used a licensed control, it fails with the exception mentioned above.
Is there any fix/workaround for this? Or any ETA on when (if ever) it will get fixed?
jnm2 commentedon May 24, 2019
@petroemil It's on the roadmap to have a preview late this year. Workarounds are here: https://github.com/dotnet/winforms/blob/master/Documentation/winforms-designer.md
This is for .NET Core but I'd expect it to work for .NET Framework as well. The workaround of having a second csproj would be a bit redundant because that's the csproj you already have to start with. :)
Visual Studio 2019 is steadily improving in this area too:
https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes#netsdk-tools
Pilzinsel64 commentedon Oct 20, 2020
I found out (not why but) when it happens. It happens as soon as the relative path to your .cs and .resx files has a white space. As soon as there is any white space, the .designer.resx will not move to .resx and stay at .cs.
How to: