Your namespace is Level1.Level2, so you need:
Imports Level1.Level2
Then you'll have
Dim TestInstance As New Simple
Keep in mind that when using the Website model in VWD Express that if you
leave off the namespaces in all files including the class files in the
App_Code directory, then a default namespace is created for you and you
won't need to import a namespace for your Simple class.
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."
"Shadow Lynx" <> wrote in message
news: oups.com...
> If this is not the most appropriate group for this question, please let
> me know.
>
> I noticed an odd priority difference in resolving names in VS 2005 (VWD
> Express) vs. the .NET 2.0 compiler (the one accessed from within VS).
>
> Let me give an example to clarify things.
>
> In a test solution, I created two web form pages with codebehinds and a
> class in the App_Code folder:
> App_Code\Simple.vb
> Default.aspx (and *.vb)
> Level2.aspx (and *.vb)
>
> App_Code\Simple.vb:
> Namespace Level1.Level2
> Public Class Simple
> Public ReadOnly Property Message() As String
> Get
> Return "Hello"
> End Get
> End Property
> End Class
> End Namespace
>
> You may have noticed the Level1.Level2 Namespace...
> Level2.aspx and *.vb contain default content - the .vb starts with
> Class Level2
>
> Default.aspx.vb: (the .aspx file contains default content)
> Imports System.Data
> Imports System.Data.SqlClient
> Imports Level1
> Partial Class _Default
> Inherits System.Web.UI.Page
> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Me.Load
> --> Dim TestInstance As New Level2.Simple
> Response.Write(TestInstance.Message)
> End Sub
> End Class
>
> When writing the code, there is no error flag on the line with the
> arrow. VS recognizes Level2.Simple properly (or maybe it's not proper)
> because of the Imports Level1 line.
>
> If I attempt to build the site, however, I get the error (due to the
> line with the arrow):
> C:\Inetpub\wwwroot\ASPX2_Test\Default.aspx.vb(9,0) : error BC30002: Type
> 'Level2.Simple' is not defined.
>
> Of course, the following replacement line makes the build process
> happy:
> Dim TestInstance As New Level1.Level2.Simple
>
> Which one is in error - the VS inline error checker or the build
> process itself? While I prefer the VS priority, the Build priority may
> be correct because the page Level2.aspx.vb contains a Level2 class
> which is actually in the same namespace (none) as the Default.aspx.vb
> page.
>
|