T
tsahiasher
the following code crashes my csc.exe (visual studio 2005):
project Base
references: System
BaseClass.cs:
namespace Base
{
public class BaseClass<T>
{
public void BaseFunc()
{
Console.WriteLine("BaseFunc");
}
}
}
project Type
references: System
TClass.cs:
namespace Type
{
public class TClass
{
public void TFunc()
{
Console.WriteLine("TFunc");
}
}
}
project Derived
references: System, Base, Type
DerivedClass.cs:
using Base;
using Type;
namespace Derived
{
public class DerivedClass : BaseClass<TClass>
{
public void DerivedFunc()
{
Console.WriteLine("DerivedFunc");
}
}
}
namespace Main
references: System, Base, Derived
Program.cs:
using Derived;
namespace ConsoleApplication1
{
class Program
{
DerivedClass _obj;
static void Main(string[] args)
{
Program x = new Program();
x.MainFunc();
}
public void MainFunc()
{
_obj = new DerivedClass();
_obj.DerivedFunc();
_obj.BaseFunc(); //crash point
}
}
}
the problem is at calling _obj.BaseFunc(); in Program.MainFunc(). if
you comment this out, the compilation succeeds. another option is to
add a reference to Type in project Main. the thing is, i don't want to
add a reference in Main to a project i'm not using directly, or even
have access to any methods defined in it. i'd like to have as much
seperation between projects as possible.
besides, if this is a syntax error, i should get an error message, not
a compiler crash.
any solutions?
project Base
references: System
BaseClass.cs:
namespace Base
{
public class BaseClass<T>
{
public void BaseFunc()
{
Console.WriteLine("BaseFunc");
}
}
}
project Type
references: System
TClass.cs:
namespace Type
{
public class TClass
{
public void TFunc()
{
Console.WriteLine("TFunc");
}
}
}
project Derived
references: System, Base, Type
DerivedClass.cs:
using Base;
using Type;
namespace Derived
{
public class DerivedClass : BaseClass<TClass>
{
public void DerivedFunc()
{
Console.WriteLine("DerivedFunc");
}
}
}
namespace Main
references: System, Base, Derived
Program.cs:
using Derived;
namespace ConsoleApplication1
{
class Program
{
DerivedClass _obj;
static void Main(string[] args)
{
Program x = new Program();
x.MainFunc();
}
public void MainFunc()
{
_obj = new DerivedClass();
_obj.DerivedFunc();
_obj.BaseFunc(); //crash point
}
}
}
the problem is at calling _obj.BaseFunc(); in Program.MainFunc(). if
you comment this out, the compilation succeeds. another option is to
add a reference to Type in project Main. the thing is, i don't want to
add a reference in Main to a project i'm not using directly, or even
have access to any methods defined in it. i'd like to have as much
seperation between projects as possible.
besides, if this is a syntax error, i should get an error message, not
a compiler crash.
any solutions?