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
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