Could not find type… Please make sure that the assembly that contains this type is referenced


  • I created a Generic User Control with following signature..

    public partial class GridMastercontrol<TMainEntity, TChildEntity> : UserControl
    where TMainEntity : class
    where TChildEntity : class
    // more code here

    A reference is created as follows-

    GridMastercontrol<STACS.ACASupp,STACS.ACALot> ctrl=
                     new GridMastercontrol<STACS.ACASupp,STACS.ACALot>();

    The control works perfectly on run-time. But, when i open the designer the design is not displayed and the following two warnings popup-

    Warning 1- Could not find type 'WindowsFormsControlLibrary1.GridMastercontrol'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU.

    Warning 2- The variable 'ctlMasterACA' is either undeclared or was never assigned.

    It was working perfectly in design mode when i did not implement the generics concept into it. but now, it does not. :(

    Please help me.. Thanks in advance :)

    Ankit Goel

    Tuesday, April 02, 2013 12:36 PM

All replies

  • A type cannot be used until the generic arguments are completed.  The windows designer has no way of knowing what generic arguments you would put into those fields, and so it fails to render the control.  

    In other words, generic user controls and classes are incompatible with the windows designer.  You'll have to do everything by hand, or change the user control to something non-generic.


    Tuesday, April 02, 2013 5:49 PM
  • I have achieved what i wanted. I just had to divide my control into two classes and everything is running fine. Thanks for the help.

    Ankit Goel

    Thursday, September 05, 2013 10:26 AM