again abstract class problems

S

Sunny

Hi again,

in the past I have posted here a problem with static methods and
abstract classes, and Jon Skeet and Richard Lowe have helped me to
clarify the things.

But now I have found another problem (I have posted similar thing in
vs.ide newsgroup, but I do not know if this is and IDE or C# problem, so
I post it here also).

So, in my solution I have:
1. base project, where I have some base classes and interfaces. Actually
I use this project in most of my solutions. Some of the classes are
abstract (with some implemented and some abstract methods). Most of the
classes here are for logging purposes, and to clarify interfaces for
structuring all my apps. For the purpose of this post I'll put the
following class:
namespace Company.Base
{
public abstract class MyVeryBaseClass
{
public static void DoBaseWork()
{
Console.WriteLine("MyVeryBaseClass.DoBaseWork called");
}

public abstract void AbstractDoWork();
}
}

2. Another base project, which is solution oriented. Here are classes
which are base for the current solution, and some of them inherits from
the previous project, and implements the abstract methods, like:

using Company.Base
// the corresponding reference in the project is set to the above
//mentioned project (add reference.../projects)
namespace Company.Solution.Base
{
public class MySolutionBase : MyVeryBaseClass
{
public override void AbstractDoWork()
{
Console.WriteLine("MySolutionBase.AbstractDoWork called");
}

public static void NewBaseMethod()
{
Console.WriteLine("MySolutionBase.NewBaseMethod called");
}

public static void NewDependentMethod
{
MySolutionBase.DoBaseWork(); //inherited
}
}
}

3. Some other projects - midtier, server and client, which I reference
to 2nd project (MySolutionBase), like:

using Company.Solution.Base
//reference set to the project
namespace Company.Solution.Client
{
public class MyClient
{
public void DoSomething()
{
MySolutionBase obj = new MySolutionBase();
obj.AbstractDoWork(); //works as expected
MySolutionBase.NewBaseMethod(); //works as expected
MySolutionBase.NewDependentMethod();
//fails to load the assembly
}
}
}

So, in all the references I have CopyLocal property set to true, in
order to copy the dependent dll's in the project bin directory.

The last project (3) has reference only to project (2), and it copies
the dll from there, but does not copy the subdependent dll, so the
execution of the lass call fails.
Yes, I know the workaround - to add a reference to MyVeryBase project,
but this does not look right to me.

My question is more general - do I miss something in the settings, or
this behavior is by design, or ... what?

And also, is this a C#/CLR limitation, or is IDE stuff?

Thanks for reading this
Sunny
 
T

Tian Min Huang

Hello Sunny,

Thanks for your post. I reviewed your description carefully, and I believe
it's the same with the original issue you posted in the vsnet.ide. I
followed your steps to create a solution with the projects in VS .NET 2003,
however, I am not able to build the solution with the following error:

h:\Test\ConsoleApplication1\bin\Debug\ClassLibrary2.dll Referenced class
'Company.Solution.Base.MySolutionBase' has base class or interface
'Company.Base.MyVeryBaseClass' defined in an assembly that is not
referenced. You must add a reference to assembly 'ClassLibrary1'.

Apparantly, it requires a reference to the MyVeryBase project in the client
project.

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
S

Sunny

Hi Tian,
I'm so ashamed :(
I haven't tested what I have posted. In my original solution it seems in
the past I have made the reference (maybe forced by such an error
message).
So sorry that I have lost your time with this.

It seems that happens only with interop assemblies in SDK, like mshtml.
While I work on the dev machine, everything is ok, without references,
because I guess it is in the GAC and server assembly does not look for
it in the bin directory, but if I move to another server, and I haven't
make a reference in the project, this dll is not there.

So, we are back to my orig. post in vs.ide group.

Sorry again
Sunny
 
T

Tian Min Huang

Hi Sunny,

It is fine and you are always welcome! :)

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top