469,927 Members | 1,399 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

C# 2.0.50727 compiler crashes

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?
Nov 22 '07 #1
2 1309
But Derived depends intrinsically on TClass from Type, so I don't see
any way you can avoid this.

I can confirm it dies horribly in 2005, but among the fatal compiler
errors (after the error report) is what you were looking for:

Error 1 The type 'Type.TClass' is defined in an assembly that is not
referenced. You must add a reference to assembly 'Type,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. D:\Develop\Test
\Final\Program.cs 20 13 Final

You can't get around this. The solution is to add the necessary
reference.

However, I have tested it in VS2008, and it works fine - i.e. the
above is the *only* error message (no compiler panic). So it looks
like this has been fixed in the new compiler.
Nov 22 '07 #2
On Nov 22, 5:53 pm, Marc Gravell <marc.grav...@gmail.comwrote:
But Derived depends intrinsically on TClass from Type, so I don't see
any way you can avoid this.

I can confirm it dies horribly in 2005, but among the fatal compiler
errors (after the error report) is what you were looking for:

Error 1 The type 'Type.TClass' is defined in an assembly that is not
referenced. You must add a reference to assembly 'Type,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. D:\Develop\Test
\Final\Program.cs 20 13 Final

You can't get around this. The solution is to add the necessary
reference.

However, I have tested it in VS2008, and it works fine - i.e. the
above is the *only* error message (no compiler panic). So it looks
like this has been fixed in the new compiler.
then how come there is no problem if i comment out the call to
_obj.BaseFunc() in Program.MainFunc()? if this was a reference
problem, then it wouldn't have mattered if i call this method or not.
Nov 25 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Kris Desmadryl | last post: by
4 posts views Thread by David Sworder | last post: by
2 posts views Thread by Sergey Golovkin via .NET 247 | last post: by
4 posts views Thread by ksukhonosenko | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.