Compile & Build works, but publish fails

Discussion in 'ASP .Net Building Controls' started by Paul, Jun 11, 2008.

  1. Paul

    Paul Guest

    Hi,

    Loosing hair today.

    I have a web site that builds, rebuilds, debugs 100%. No problem. When I run
    "Publish" though, it fails. Error in Output is:
    "error BC30002: Type 'ASP.controls_questioncontrol_ascx' is not defined."

    Now, questioncontrol is a "web user control" that is part of the project.

    I have this in the aspx file (it errors on this line)
    <%@ Register Src="~/Controls/QuestionControl.ascx" TagName="QuestionControl"
    TagPrefix="uc1" %>

    I have this in the code behind file (it errors on this line)
    Protected WithEvents u_ctrl_DetailedQuestionsPerPage As
    ASP.controls_questioncontrol_ascx

    Using framework 3.5 VS2008

    Any help would be appreciated.
    Thanks
    Paul
     
    Paul, Jun 11, 2008
    #1
    1. Advertising

  2. Hi Paul,

    From your description, you're encountering the following error when try
    publishing (precompile) an ASP.NET 2.0 web site project, correct?

    "error BC30002: Type 'ASP.controls_questioncontrol_ascx' is not defined."

    Based on my experience, such error is mostly caused by the precompilation
    of some page's code file can not resolve a certain type(which is used in
    the code). For your scenario, that problem type is a usercontrol's
    codebehind class, and you have the following line to use it in a certain
    code file:

    ===================
    Protected WithEvents u_ctrl_DetailedQuestionsPerPage As
    ASP.controls_questioncontrol_ascx
    ===================

    would you tell me where did you put the above member field, in another aspx
    page or ascx control's code behind?

    Since ASP.NET 2.0 use dynamic compilation, two different page or
    usercontrol are not guaranteed to be compiled into the same assembly. Thus,
    if you want to reference the codebehind class type of another aspx page or
    ascx usercontrol in a given page's codebehind, you need to add the
    "@Reference" directive to explicitly indicate the ASP.NET runtime to
    compile them into same assembly. e.g.

    =========
    <%@ Reference virtualPath="[path to your ascx user control]" %>
    ==================

    #@ Reference
    http://msdn.microsoft.com/en-us/library/w70c655a.aspx

    #How to Programtically Include ASP.Net User Controls
    http://www.netomatix.com/development/usercontrols2.aspx

    Please feel free to let me know if there is anything unclear.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.
    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------
    >From: =?Utf-8?B?UGF1bA==?= <>
    >Subject: Compile & Build works, but publish fails
    >Date: Wed, 11 Jun 2008 09:05:01 -0700


    >
    >Hi,
    >
    >Loosing hair today.
    >
    >I have a web site that builds, rebuilds, debugs 100%. No problem. When I

    run
    >"Publish" though, it fails. Error in Output is:
    >"error BC30002: Type 'ASP.controls_questioncontrol_ascx' is not defined."
    >
    >Now, questioncontrol is a "web user control" that is part of the project.
    >
    >I have this in the aspx file (it errors on this line)
    ><%@ Register Src="~/Controls/QuestionControl.ascx"

    TagName="QuestionControl"
    >TagPrefix="uc1" %>
    >
    >I have this in the code behind file (it errors on this line)
    > Protected WithEvents u_ctrl_DetailedQuestionsPerPage As
    >ASP.controls_questioncontrol_ascx
    >
    >Using framework 3.5 VS2008
    >
    >Any help would be appreciated.
    >Thanks
    >Paul
    >
     
    Steven Cheng [MSFT], Jun 12, 2008
    #2
    1. Advertising

  3. Paul

    Paul Guest

    Hi,

    Thanks for giving me some ideas.

    In the end I only did 2 things:

    1. Added the following to the control's directive:
    Classname="myControlName"
    2. In the asp code behind, I refer to the classname above, not to
    asp.mycontrol

    Thanks
    Paul

    "Steven Cheng [MSFT]" wrote:

    > Hi Paul,
    >
    > From your description, you're encountering the following error when try
    > publishing (precompile) an ASP.NET 2.0 web site project, correct?
    >
    > "error BC30002: Type 'ASP.controls_questioncontrol_ascx' is not defined."
    >
    > Based on my experience, such error is mostly caused by the precompilation
    > of some page's code file can not resolve a certain type(which is used in
    > the code). For your scenario, that problem type is a usercontrol's
    > codebehind class, and you have the following line to use it in a certain
    > code file:
    >
    > ===================
    > Protected WithEvents u_ctrl_DetailedQuestionsPerPage As
    > ASP.controls_questioncontrol_ascx
    > ===================
    >
    > would you tell me where did you put the above member field, in another aspx
    > page or ascx control's code behind?
    >
    > Since ASP.NET 2.0 use dynamic compilation, two different page or
    > usercontrol are not guaranteed to be compiled into the same assembly. Thus,
    > if you want to reference the codebehind class type of another aspx page or
    > ascx usercontrol in a given page's codebehind, you need to add the
    > "@Reference" directive to explicitly indicate the ASP.NET runtime to
    > compile them into same assembly. e.g.
    >
    > =========
    > <%@ Reference virtualPath="[path to your ascx user control]" %>
    > ==================
    >
    > #@ Reference
    > http://msdn.microsoft.com/en-us/library/w70c655a.aspx
    >
    > #How to Programtically Include ASP.Net User Controls
    > http://www.netomatix.com/development/usercontrols2.aspx
    >
    > Please feel free to let me know if there is anything unclear.
    >
    > Sincerely,
    >
    > Steven Cheng
    >
    > Microsoft MSDN Online Support Lead
    >
    >
    > Delighting our customers is our #1 priority. We welcome your comments and
    > suggestions about how we can improve the support we provide to you. Please
    > feel free to let my manager know what you think of the level of service
    > provided. You can send feedback directly to my manager at:
    > .
    >
    > ==================================================
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    > ications.
    >
    > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    > where an initial response from the community or a Microsoft Support
    > Engineer within 1 business day is acceptable. Please note that each follow
    > up response may take approximately 2 business days as the support
    > professional working with you may need further investigation to reach the
    > most efficient resolution. The offering is not appropriate for situations
    > that require urgent, real-time or phone-based interactions or complex
    > project analysis and dump analysis issues. Issues of this nature are best
    > handled working with a dedicated Microsoft Support Engineer by contacting
    > Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/subscriptions/support/default.aspx.
    > ==================================================
    > This posting is provided "AS IS" with no warranties, and confers no rights.
    > --------------------
    > >From: =?Utf-8?B?UGF1bA==?= <>
    > >Subject: Compile & Build works, but publish fails
    > >Date: Wed, 11 Jun 2008 09:05:01 -0700

    >
    > >
    > >Hi,
    > >
    > >Loosing hair today.
    > >
    > >I have a web site that builds, rebuilds, debugs 100%. No problem. When I

    > run
    > >"Publish" though, it fails. Error in Output is:
    > >"error BC30002: Type 'ASP.controls_questioncontrol_ascx' is not defined."
    > >
    > >Now, questioncontrol is a "web user control" that is part of the project.
    > >
    > >I have this in the aspx file (it errors on this line)
    > ><%@ Register Src="~/Controls/QuestionControl.ascx"

    > TagName="QuestionControl"
    > >TagPrefix="uc1" %>
    > >
    > >I have this in the code behind file (it errors on this line)
    > > Protected WithEvents u_ctrl_DetailedQuestionsPerPage As
    > >ASP.controls_questioncontrol_ascx
    > >
    > >Using framework 3.5 VS2008
    > >
    > >Any help would be appreciated.
    > >Thanks
    > >Paul
    > >

    >
    >
     
    Paul, Jun 12, 2008
    #3
  4. Thanks for your reply Paul,

    Yes, I think using "ClassName" attribute is a good idea. Actually, that
    makes the ASP.NET runtime compile your ascx usercontrol's codebehind class
    into the specified type name instead of a augogenarated one. Thus, other
    pages reference via the "ClassName" can work correctly without explicitly
    use @reference directive.

    If you need any further help later, welcome to post here.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.
    =====================
    This posting is provided "AS IS" with no warranties, and confers no rights.


    --------------------
    >From: =?Utf-8?B?UGF1bA==?= <>
    >References: <>

    <>
    >Subject: RE: Compile & Build works, but publish fails
    >Date: Thu, 12 Jun 2008 02:20:02 -0700


    >
    >Hi,
    >
    >Thanks for giving me some ideas.
    >
    >In the end I only did 2 things:
    >
    >1. Added the following to the control's directive:
    >Classname="myControlName"
    >2. In the asp code behind, I refer to the classname above, not to
    >asp.mycontrol
    >
    >Thanks
    >Paul
    >
    >"Steven Cheng [MSFT]" wrote:
    >
    >> Hi Paul,
    >>
     
    Steven Cheng [MSFT], Jun 12, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr Marsh
    Replies:
    2
    Views:
    324
    Peter Marsh
    Nov 4, 2003
  2. M. Craig
    Replies:
    2
    Views:
    6,107
    M. Craig
    Nov 19, 2003
  3. Nagaraj
    Replies:
    1
    Views:
    888
    Lionel B
    Mar 1, 2007
  4. =?Utf-8?B?Z3V5?=

    Build works but will not compile

    =?Utf-8?B?Z3V5?=, Oct 18, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    308
    Alexey Smirnov
    Oct 18, 2007
  5. Tim Royal
    Replies:
    0
    Views:
    731
    Tim Royal
    Aug 28, 2008
Loading...

Share This Page