asp.net 2.0 type not defined

P

phil

I recently tried converting my asp.net 1.1 app to 2.0 in visual studio
2005 beta 2.

I get several "type xxx is not defined" errors.

It seems that some of my code file within my web application can no
longer see the types defined in my asp.vb files.

Here is a simple example:

default2.aspx.vb

Partial Public Class Default2
Inherits System.Web.UI.Page

Public m_1 As Integer

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

Dim testc As New Class1
testc.load(Me)
End Sub
End Class

class1.vb

Public Class Class1

Public Sub load(ByVal p As Default2)

' ???
End Sub
End Class


class1.vb is in the App_Code directory.

the error is reported for class1.vb is:

Type "Default2" is not defined

why can't class1 see the type defined in the aspx.vb file?

something obvious i am sure, but i remain confused.
 
S

Scott Allen

Hey Phil,

I've heard this scenario should be working by the time 2.0 releases.

The problem is App_Code compiles into an assembly that does not
reference any of the assemblies containing web forms (because those
assemblies all reference App_Code and we don't want circular
references).

I believe what the ASP.NET team plans to do is generate stub classes
in App_Code, you could do the same to work around the problem now.

A stub class would be a base class that your web form code behind
class derives from. That gives you a Type you can use from App_Code to
manipulate the web form.

Something else you might consider is defining an interface in App_Code
for one or more web forms to inherit. Give the interface properties
and methods that will be common to the form(s) you need to interact
with and do so through the interface type instead of the web form
class.
 
P

phil

thanks Scott. your suggestion works fine. the problem is both obvious
and perplexing; i thought there was some implied/hidden namespace for
the web form side that i was missing. i bit perplexing because you
would think this would happen often enough that the fixes would have
been in beta 2.

is there a good document somewhere that describes the major things
microsoft plans to do between now and release? so far, this seems like
the only serious work around i will need to convert my application, but
i'd like to know what they know now...

thanks again for the great suggestion and prompt reply.

/phil
 

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

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
VetaMcRae
Top