0

I am running a web server using VB.net and I have a bunch of pages that need to utilize similar functionality, so I was thinking of creating a shared base class that incorporates all of this shared functionality. I created a file call it SharedBaseClass.vb, and I also have a class that should inherit from this class, SubClass.aspx.vb. The Top few lines of the the parent class look like this:

Partial Class SharedBaseClass Inherits System.Web.UI.Page 

And of the child class that should inherit:

Partial Class SubClass Inherits SharedBaseClass 

Then at the top of the SubClass.aspx file it looks like this:

<%@ Page Title="" Language="VB" MasterPageFile="~/Main_SA.master" AutoEventWireup="false" Src="SubClass.aspx.vb" Inherits="SubClass" %> 

Assume that all of these files are located in the same directory.

But when I try to run this, I get an error: Compiler Error Message: BC30002: Type 'SharedBaseClass' is not defined. And then the highlighted error is on the line that reads: Inherits SharedBaseClass

I've also tried importing the file to no avail. What am I doing wrong?

2 Answers 2

2

The class SharedBaseClass must be public and code file SharedBaseClass.vb must be located under App_Code folder.

Public Partial Class SharedBaseClass Inherits System.Web.UI.Page .... 
Sign up to request clarification or add additional context in comments.

7 Comments

You should remove the Shared statement from the class since that is not allowed in VB.Net.
@competent_tech - Thanks budy! It should be partial, not a shared.
still is giving me the same issue after I make the base class public. I'm actually editing this code outside of Microsoft Visual Studio. Is it possible that this is the issue? Does visual studio automate importing files and creating bundles that are used when the code is compiled?
@ecbtln - The code file SharedBaseClass.vb must be placed inside the App_Code folder in your web-app.
thought that would work, still not sure what's wrong. do I need to import it as well? or is it automatically imported?
|
1

One other item to check, which isn't as big an issue in VB.Net as it is in C# is to make sure that if you have a Namespace specified in SharedBaseClass, that the same Namespace is specified for the inherited classes.

1 Comment

I got it. it turns out it was an issue with where my App_Code folder was being stored

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.