Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 4th, 2009, 02:02 PM
Registered User
 
Join Date: Oct 2009
Location: NYC
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Skype™ to nqsousa
Unhappy Error using public class in App_Code: BC30002: Type 'xxx' is not defined

Hi,

I am experiencing a problem when deploying a website to IIS 7.0. I have no problem when running the website in VWD 2008 Express Edition (localhost).

The error occurs when I try to view a page which uses a code-behind file containing a reference to a public class(defined under a code file under App_Code folder).
page7.aspx uses page7.aspx.vb as its code-behind page
Contents of page7.aspx.vb page are:
Quote:
Imports Class2
Partial Class Page7
Inherits System.Web.UI.Page


Protected Sub LinkButton3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton3.Click
Response.Redirect("Default.aspx")
End Sub

Protected Sub LinkButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton2.Click
Dim class2_api As New Class2
class2_api.displayalert(TextBox1.Text)
End Sub
End Class
There's a file named Class2.vb in the App_Code folder that contains:
Code:
Imports Microsoft.VisualBasic
Imports System.Web.UI.Page

Public Class Class2
    Inherits System.Web.UI.Page
    Sub displayalert(ByVal msg As String)
        MsgBox(msg)
    End Sub
End Class
I am using the Copy Web Site functionality in VWD2008 Exp to deploy the website to a subfolder in inetpub (IIS 7.0) folder.

I have other test pages in website which work fine as long as there is no reference to a public class.

Any help would be greatly appreciated.
Reply With Quote
  #2 (permalink)  
Old November 4th, 2009, 04:14 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,346
Thanks: 0
Thanked 5 Times in 5 Posts
Default

What is the exact error message?

I believe the problem is that you are using a MsgBox(). MsgBox and MessagBox() will only display on the server, not the client pc. It works locally, because your PC is both the client and the server.
Reply With Quote
The Following User Says Thank You to jbenson001 For This Useful Post:
nqsousa (December 8th, 2009)
  #3 (permalink)  
Old November 6th, 2009, 05:20 PM
Registered User
 
Join Date: Oct 2009
Location: NYC
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Skype™ to nqsousa
Smile BC30002: Type 'xxx' is not defined - Problem was solved

Hi jbenson001,
The problem occurred no matter what specific procedures or functions were inside the public class that I was trying to use.
In the meantime I solved it by doing the following:

a) I changed the location where I was deploying the site in IIS 7.0: before I had the site apart from the Default Web Site. I now have the site as a sub-folder of the Default Web Site. The website is also now defined as an Application (running under the DefaultAppPool)
b) I stopped the IIS server (stopped WorldWideWeb service), and changed start mode to manual
c) I restarted the machine
d) I deleted all files under folder C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET Files\ (I couldn't delete all until server had stopped) - this included some compiled files from the Visual Studio 2008 development testing
d) I changed WWW Service mode back to Automatic and restarted IIS Server
e) restarted Visual Studio 2008, built site, and published site to new location (under c:\inetput\wwwroot\<applicationfoldername>
The problem did not recur.

I think the issue was that for some reason the compilation of the website files upon publishing was not done properly when the site was defined in paralell with Default Web Site (as opposed to nder). It was probably in the configuration of the site itself. When you put the site working under the Default Web Site we benefit from all the inherited configurations that exist for the Default Web Site.
I also found useful deleting the temporary asp.net files. Later I did experience other error messages where it seems that the compiled files from opening the site from Visual Studio 2008, conflicted with the dlls from the compilation of the site into the IIS deployment and those errors would be solved by simply stopping the server, deleting temp files and restarting server.
Reply With Quote
  #4 (permalink)  
Old December 8th, 2009, 04:27 AM
Registered User
 
Join Date: Oct 2009
Location: NYC
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Skype™ to nqsousa
Default Error finally debugged

jbenson001,
after tinkering a few more days with the problem occurring and me getting annoyed at the solution i had pointed in prior post (which required stopping server and cleaning temp files), the problem was that I had several vb. code-behind files containing the same Partial Class name and **** and this was the problem **** with the same procedures and function names inside the partial class.
This occurred because I did copy/paste to some files (and respective vb code-behind) and left them on the solution without editing the partial class name.
The compiler was simply unable to load the class properly when it had the same procedure/function in more than one location in a partial class with the same name.
Tracking this was not so easy because - I think - the compilation of the components of the partial class only occur when the specific page is involved in a request.

Hopefully this is helpful in future cases of this error.
Reply With Quote
  #5 (permalink)  
Old December 13th, 2009, 01:34 AM
Registered User
 
Join Date: Dec 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have the same situation. The difference of what I did is I put all .vb files in web root. My .aspx page can call function in page7.aspx.vb just fine. But when importing a file like Class2.vb in page7.aspx.vb, the .aspx won't recognize the class type in Class2.vb and throws error like

BC30002: Type 'Class2' is not defined

I even added Namespace in Class2.vb as suggested by other forum. Not working either. It seems the page7.aspx.vb is not able to find Class2.vb, because renaming the imports statement to something doesn't exist

Imports Class2
to
Imports Class2blah

resulting into same error too. It seems this is some sort of config error. Class2.vb needs to be linked to page7.aspx.vb in some ways. I'm NOT using MS Studio. Anybody knows a way to make this work without MS studio?
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Classes in App_Code "not defined"!? LenexaKS ASP.NET 2.0 Professional 7 December 10th, 2007 01:23 PM
Error : BC30002: Type 'xxx' is not defined. cmualo ASP.NET 2.0 Basics 2 June 20th, 2007 08:25 AM
App_Code class compiled twice? xxx exists in both bigluzer General .NET 5 January 5th, 2007 02:45 PM
BC30002: Type 'OLEDBConnection' is not defined. athanatos ASP.NET 1.0 and 1.1 Basics 1 July 5th, 2006 09:03 PM
Saving a Public Property created in App_Code striker9 ASP.NET 2.0 Basics 1 June 8th, 2006 02:18 PM



All times are GMT -4. The time now is 01:10 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.