Accessing Classes
Accessing Classes
Accessing Classes
Accessing Classes
Accessing Classes
Accessing Classes Accessing Classes Accessing Classes Accessing Classes Accessing Classes Accessing Classes Accessing Classes Accessing Classes
Accessing Classes Accessing Classes
Accessing Classes
Go Back  Xtreme Visual Basic Talk > > > Accessing Classes


Reply
 
Thread Tools Display Modes
  #1  
Old 01-06-2012, 03:00 PM
phb2911's Avatar
phb2911 phb2911 is offline
Regular
 
Join Date: Mar 2009
Location: Manville, NJ USA
Posts: 54
Default Accessing Classes


I created a class file Class1.vb into the App_Code folder, the content of the file is:

Code:
Public Class Class1

    Public Shared ReadOnly Property Foo() As String
        Get
            Return "Shared Property Foo."
        End Get
    End Property

    Public ReadOnly Property Bar() As String
        Get
            Return "Property Bar."
        End Get
    End Property

End Class
Then I created a web page and added to labels. On the page Load event I wrote the following code:

Code:
    
    ' shared property
    Label1.Text = Class1.Foo

    Dim sc As New Class1
    Label2.Text = sc.Bar
When I run the web site using the ASP.Net Development Server provided by Visual Studio.Net, everything works fine. When I use IIS, it doesn't. It's like the class is not being accessed by the web page. The only way I get the web page to work properly is when I copy the class code to the .aspx.vb file. But then I'm gonna have to copy the class into each web page!

Can anyone pleas tell me how to make this class accessible to all other files?

Thanks.
Reply With Quote
  #2  
Old 01-07-2012, 07:00 AM
PlausiblyDamp's Avatar
PlausiblyDampAccessing Classes PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

If the class file is in the App_Code folder then it should work under IIS the same as it does with the development server. Is it giving any specific errors?
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 01-07-2012, 09:22 AM
phb2911's Avatar
phb2911 phb2911 is offline
Regular
 
Join Date: Mar 2009
Location: Manville, NJ USA
Posts: 54
Default

Yes, this is what I'm getting:

'Class1' is not declared. It may be inaccessible due to its protection level.

I'm getting the same error when I access the site under IIS in my local machine and also when I upload it to a remote server. As I sad before it only works under the development server.

I'm thinking it may have something to do with some IIS config.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Accessing Classes
Accessing Classes
Accessing Classes Accessing Classes
Accessing Classes
Accessing Classes
Accessing Classes Accessing Classes Accessing Classes Accessing Classes Accessing Classes Accessing Classes Accessing Classes
Accessing Classes
Accessing Classes
 
Accessing Classes
Accessing Classes
 
-->