Visual Web Developer 2005 Classes in Code Folder Problem

G

Guest

I have an aspx page that does not have a separate source for the VB - it is
on top in between the <script> tags. I use the following statement

Dim oComLib as New ComLib

To reference a class called ComLib in a source member called ComLib.vb that
is found in the /Code folder of my project. It all works fine in the VWD2005
environment as when I run the aspx page, it processes the above statment and
"sees" the class reference in the code.

When I upload the /Code folder (and its contents) to a remote web server
running the 1.1 environment and then upload the .aspx page (which isn't in
the /Code folder) when the page comes across the above statement, I get the
error below. My questions are:

1) How do I get the .aspx page to "see" the ComLib class source file that is
in the /Code folder (which is where VWD2005 dictates it should be put if you
want it to be "generally consumable")
2) I don't want to /bin dll any of this, I want it all to interpret and
compile on the fly
3) Do I need to register the /Code/ComLib.vb on the 1.1 server in some way?
4) If I need to do a /bin dll using VWD2005, how do I do it as when I do a
build, nothing is put into a /bin folder
5) When I ran another .aspx page built in VWD2005 and uploaded to the same
remote web server that didn't reference anything like the /Code/ComLib.vb, it
ran fine without creating a dll and just having all the vb/html source within
one .aspx

Finally, the source member for class /Code/ComLib.vb has as it's first
statement

Public Class ComLib

so that should make it be referenced anywhere.

If someone could help that would be great - I searched and could not find
anything on this subject.

---------------------------------------------------------------------------------------------
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30002: Type 'ComLib' is not defined.

Source Error:

Line 2: <script runat="server">
Line 3:
Line 4: Dim oComlib As New ComLib
Line 5:
Line 6: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
---------------------------------------------------------------------------------------------
 
J

John Saunders

tonelab said:
I have an aspx page that does not have a separate source for the VB - it is
on top in between the <script> tags. I use the following statement

Dim oComLib as New ComLib

To reference a class called ComLib in a source member called ComLib.vb
that
is found in the /Code folder of my project. It all works fine in the
VWD2005
environment as when I run the aspx page, it processes the above statment
and
"sees" the class reference in the code.

When I upload the /Code folder (and its contents) to a remote web server
running the 1.1 environment and then upload the .aspx page (which isn't in
the /Code folder) when the page comes across the above statement, I get
the
error below. My questions are:

VWD2005 works with Framework 2.0, not 1.1.

John Saunders
 
G

Guest

<, VWD2005 works with Framework 2.0, not 1.1. >>

That's not completely true - I have created standalone .aspx pages in
VWD2005 that have both vb source and html in one .aspx file, uploded that
..aspx file to a 1.1 server and it runs just fine without creating a /bin dll.
It no different than creating an all inclusive .aspx file in WebMatrix and
uploading it to a 1.1 machine. So your statement is not completely correct -
you can create an .aspx page in VWD2005 that doesn't use a codebehind file
but rather is all-in-one, upload it to a 1.1 server and it will run perfectly.

Your statement is correct in that VWD2005 needs the 2.0 framework for
development purposes.

Can anyone else help me with the /Code folder question i posted previously?

Or is the only way that a 1.1 server can see a class file in a /code folder
(or anyo other folder for that matter) is by creating the /bin dll?
 
J

John Saunders

tonelab said:
<, VWD2005 works with Framework 2.0, not 1.1. >>

That's not completely true - I have created standalone .aspx pages in
VWD2005 that have both vb source and html in one .aspx file, uploded that
.aspx file to a 1.1 server and it runs just fine without creating a /bin
dll.
It no different than creating an all inclusive .aspx file in WebMatrix and
uploading it to a 1.1 machine. So your statement is not completely
correct -
you can create an .aspx page in VWD2005 that doesn't use a codebehind
file
but rather is all-in-one, upload it to a 1.1 server and it will run
perfectly.

Actually, you're just using VWD2005 as a fancy text editor. You could have
created the same application in Notepad, with the same amount of success.

The reason being that 1.1 doesn't know anything about a Code folder, or
about compiling code on the fly. That's a 2.0 feature.

John Saunders
 
G

Guest

Thanks for your perseverence in anwering this thread. Perhaps I can simplify
with an example:
-------------------------------------------------------------------
This file is called stored in /Code/ClassFile.vb

Imports System
Namespace ClassFile
Public Class ClassFile1
Public function GetTimer() as string
GetTimer = Timer.ToString
End Function
End Class
End Namespace
-----------------------------------------------------------------------------
This all in one page is saved in /Content/WebPage1.aspx

<%@ Page Language="VB" %>
<%@ Import Namespace="ClassFile"%>
<script runat="server">

' Insert page code here
'
dim oClassFile as new ClassFile1
Sub Button1_Click(sender As Object, e As EventArgs)
Button1.Text = oClassFile.GetTimer
End Sub

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:Button id="Button1" onclick="Button1_Click" runat="server"
Text="Button"></asp:Button>
<!-- Insert content here -->
</form>
</body>
</html>
----------------------------------------------------------------------
How do I make this work in 1.1 so that WebPage1.aspx can call the class
saved in ClassFile.vb without compiling a /bin dll? The inherits doesn't seem
to do it. All I really want is to be able to use a class found in another
source member. There has to be something that tells it where to look for
additional stuff.

The old asp way was to just put your classes into a source file and then use
the #include statement, to use an analogy.

Thanks
George
 
J

John Saunders

tonelab said:
Thanks for your perseverence in anwering this thread. Perhaps I can
simplify
with an example:
-------------------------------------------------------------------
This file is called stored in /Code/ClassFile.vb

Imports System
Namespace ClassFile
Public Class ClassFile1
Public function GetTimer() as string
GetTimer = Timer.ToString
End Function
End Class
End Namespace
-----------------------------------------------------------------------------
This all in one page is saved in /Content/WebPage1.aspx

<%@ Page Language="VB" %>
<%@ Import Namespace="ClassFile"%>
<script runat="server">

' Insert page code here
'
dim oClassFile as new ClassFile1
Sub Button1_Click(sender As Object, e As EventArgs)
Button1.Text = oClassFile.GetTimer
End Sub

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:Button id="Button1" onclick="Button1_Click" runat="server"
Text="Button"></asp:Button>
<!-- Insert content here -->
</form>
</body>
</html>
----------------------------------------------------------------------
How do I make this work in 1.1 so that WebPage1.aspx can call the class
saved in ClassFile.vb without compiling a /bin dll? The inherits doesn't
seem
to do it. All I really want is to be able to use a class found in another
source member. There has to be something that tells it where to look for
additional stuff.

Sorry, there isn't anything like this. It's a 2.0 feature.

John Saunders
 
G

Guest

so the bottom line to this whole long thread is that in 1.1 without creating
a /bin dll, there is no way for a codebehind vb file to see anything outside
of it's file and there is no way to emulate the old asp include= statement to
"bring in" any code from an external source file, is that correct?

what a shame.

George
 
J

John Saunders

tonelab said:
so the bottom line to this whole long thread is that in 1.1 without
creating
a /bin dll, there is no way for a codebehind vb file to see anything
outside
of it's file and there is no way to emulate the old asp include= statement
to
"bring in" any code from an external source file, is that correct?

There are very good reasons why the old way is the old way. For instance, if
you #include a class into one file, and also #include it in another, are
they the same class, or different classes?

This isn't scripting, it's programming. It's different.

John Saunders
 

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