views:

31

answers:

1

Greetings,

I just converted an ASP.NET Web Site Project to a Web Application Project in VS 2010. After I run the application though it seems that my class polymorphism broke. I don't have a clue as to why this could occur.

So in the following code when I call base.OnLoad(e) I am getting errors in the base class because the variable myString is null. In fact all the variables for the Base class are null. I can do

base.myString = this.myString;

before

base.OnLoad(e);

but this doesn't seem to be polymorphic to me.


Code:

public partial class FormA : Web.ClassB 
{
    protected override void OnLoad(EventArgs e)
    {
        myString = "TEST";

        base.OnLoad(e);
    }
}

public class ClassB 
{
    protected String myString;

    protected override void OnLoad(EventArgs e)
    {
        // Class C has a virtual OnLoad method (not shown here)
    }
}
A: 

It looks like ClassB is in a namespace or a member of another class. Do you have your namespaces/scoping correct because I have ran into problems like that converting web sites to web apps.

Robert
Ahh, I think you might have nailed this one on the head. But I still feel well, stuck with a dillema. In my solution I have 3 projects (3 seperate assemblies), and my Class B is in the Class Library (namespace = "Lib") and Class A is in the web project (default namespace = "Web"). Do I have to use the same namespace for both projects? Can it be "Base.Lib" and "Base.Web"?
Sephrial