2

In my WinForms project (VS2010, .NET 4.0) I had a user control named MyView, which was derived from System.Windows.Forms.UserControl. Then I modified this control to be Generic User Control:

Partial Class MyView(Of TEntity As {New, Class})
        Inherits System.Windows.Forms.UserControl

     ' source code here

End Class

Unfortunately, auto-generated InitializeComponent() code from VS Winforms Designer is supplied with vb.net syntax error and produce compilation error:

    Dim resources As System.ComponentModel.ComponentResourceManager = 
New System.ComponentModel.ComponentResourceManager(GetType(MyView)) 

Instead of above line of code, there should be:

    Dim resources As System.ComponentModel.ComponentResourceManager = 
New System.ComponentModel.ComponentResourceManager(GetType(MyView(Of TEntity)))

How can I fix this behavior of VS2010 WinForms Designer?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
sgnsajgon
  • 664
  • 2
  • 13
  • 56
  • The base class of my user control is `System.Windows.Forms.UserControl` (so non-generic). I have a problem with syntax error and compilation failure after `InitializeComponent()` code re-generation. If I fix this syntax manually, I am able to open this control in VS Designer. My problem is rather related to this issue: http://stackoverflow.com/a/1627518/823040 – sgnsajgon Apr 08 '13 at 21:26
  • There is a solution to get around this issue: [link](http://stackoverflow.com/a/14849745/823040). That one fix is quite similar to known method for fix up VS limitation of using VS Winforms Designer with controls and forms that are derived from Generic type. However It involves creating of additional accessory class. I wonder is there a prettier solution. – sgnsajgon Apr 10 '13 at 10:21

1 Answers1

0

Related topic with some explanations and proposed workaround: Fix embedded resources for a generic UserControl

The chances are that It's bug up to VS2010.

Bypass way is quite similar to known method for fix up VS limitation of using VS Winforms Designer with controls and forms that are derived from Generic type. However It involves creating of additional accessory class.

Community
  • 1
  • 1
sgnsajgon
  • 664
  • 2
  • 13
  • 56