Compile & Build works, but publish fails

P

Paul

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
 
S

Steven Cheng [MSFT]

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:
(e-mail address removed).

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

Paul

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 said:
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:
(e-mail address removed).

==================================================
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==?= <[email protected]>
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
 
S

Steven Cheng [MSFT]

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:
(e-mail address removed).

==================================================
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==?= <[email protected]>
References: <[email protected]>
Subject: RE: Compile & Build works, but publish fails
Date: Thu, 12 Jun 2008 02:20:02 -0700
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top