PC Review


Reply
Thread Tools Rate Thread

Cyclic DLL references

 
 
Yair
Guest
Posts: n/a
 
      13th Jan 2004
Is it possible in any way to have a cyclic DLL reference
in .NET? (We need DLL A to hold a reference to DLL B, and
vice versa). If it is not possible, does anyone know of
any good trick of how to accomplish this?
Thank you in advance.
 
Reply With Quote
 
 
 
 
Matthias Straka
Guest
Posts: n/a
 
      13th Jan 2004
What do you want to use the cyclic dependency for? Maybe you can introduce a
third dll defining common interfaces and reference to that in both dlls. The
classed you want to be able to communicate with each other can then be
derived from one of these interfaces.

You now have three Dlls: A, B and Interfaces
A references B and Interfaces
B references only Interfaces

Let's say you want to use some class from A in B, set a static
member(datatype: interface defined in interfaces) of some class in B to a
valid object from A by a call from A. Any class in B can now access this
member and the object implementing the interface.

DLL: Interfaces
interface IAClass
{
foo();
}

DLL:A
class AClass:IAClass
{
foo(){...}
setClass()
{
BClass.aclass=this;
}

}

DLL:B
class BClass
{
public static IAClass aclass;
bar()
{
aclass.foo();
}
}


Or create the object via reflection (class Activator + GetType(...) from the
Assembly-Object of A found in AppDomain.CurrentDomain.GetAssemblies()).

Anyone got a better idea?

mat

"Yair" <(E-Mail Removed)> schrieb im Newsbeitrag
news:06ca01c3d9f2$28ce5630$(E-Mail Removed)...
> Is it possible in any way to have a cyclic DLL reference
> in .NET? (We need DLL A to hold a reference to DLL B, and
> vice versa). If it is not possible, does anyone know of
> any good trick of how to accomplish this?
> Thank you in advance.



 
Reply With Quote
 
Yair
Guest
Posts: n/a
 
      14th Jan 2004
Hi,
Thank you for your reply.
The reason me need to have cyclic references is that we
are working on quite a large project, and
we have now reached the conclusion that we need to
seperate a certain DLL to about a dozen DLL's (so that it
will be easier for the developers to work on their models).
The problem is that we have cyclic dependencies in this
DLL.
The only problem with your proposal is the perforance
penalty (quick access from A to B, and from B to A is a
key issue).
Anyway, thanks alot. We'll keep thinking about it :-)...

>-----Original Message-----
>What do you want to use the cyclic dependency for? Maybe

you can introduce a
>third dll defining common interfaces and reference to

that in both dlls. The
>classed you want to be able to communicate with each

other can then be
>derived from one of these interfaces.
>
>You now have three Dlls: A, B and Interfaces
>A references B and Interfaces
>B references only Interfaces
>
>Let's say you want to use some class from A in B, set a

static
>member(datatype: interface defined in interfaces) of some

class in B to a
>valid object from A by a call from A. Any class in B can

now access this
>member and the object implementing the interface.
>
>DLL: Interfaces
>interface IAClass
>{
>foo();
>}
>
>DLL:A
>class AClass:IAClass
>{
>foo(){...}
>setClass()
>{
> BClass.aclass=this;
>}
>
>}
>
>DLL:B
>class BClass
>{
>public static IAClass aclass;
>bar()
>{
>aclass.foo();
>}
>}
>
>
>Or create the object via reflection (class Activator +

GetType(...) from the
>Assembly-Object of A found in

AppDomain.CurrentDomain.GetAssemblies()).
>
>Anyone got a better idea?
>
>mat
>
>"Yair" <(E-Mail Removed)> schrieb im

Newsbeitrag
>news:06ca01c3d9f2$28ce5630$(E-Mail Removed)...
>> Is it possible in any way to have a cyclic DLL reference
>> in .NET? (We need DLL A to hold a reference to DLL B,

and
>> vice versa). If it is not possible, does anyone know of
>> any good trick of how to accomplish this?
>> Thank you in advance.

>
>
>.
>

 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      14th Jan 2004
Yair <(E-Mail Removed)> wrote:
> Hi,
> Thank you for your reply.
> The reason me need to have cyclic references is that we
> are working on quite a large project, and
> we have now reached the conclusion that we need to
> seperate a certain DLL to about a dozen DLL's (so that it
> will be easier for the developers to work on their models).
> The problem is that we have cyclic dependencies in this
> DLL.
> The only problem with your proposal is the perforance
> penalty (quick access from A to B, and from B to A is a
> key issue).


Are you *sure* it's a problem? Have you tested it and measured the
performance penalty? You may well find it's not nearly as bad as you
think, and not enough to be a problem.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
Conrad Zhang
Guest
Posts: n/a
 
      15th Jan 2004
Try this:
Step 1. A, standalone.
2. Add B, reference A.
3. Rebuild A, reference B.
Now you have cyclic dependency between A and B.

"Yair" <(E-Mail Removed)> wrote in message
news:06ca01c3d9f2$28ce5630$(E-Mail Removed)...
> Is it possible in any way to have a cyclic DLL reference
> in .NET? (We need DLL A to hold a reference to DLL B, and
> vice versa). If it is not possible, does anyone know of
> any good trick of how to accomplish this?
> Thank you in advance.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How remove invalid references in Tools>References drop down box? EagleOne@discussions.microsoft.com Microsoft Excel Programming 1 7th Jul 2009 09:52 AM
Help with converting a block of cells with Absolute and mixed references to relative references Vulcan Microsoft Excel Worksheet Functions 3 13th Dec 2007 11:43 PM
references adding themselves based on references from other projects referenced Brian Henry Microsoft VB .NET 1 22nd Jul 2005 06:35 PM
Are Cyclic dependencies allowed in file references? Brian Sabolik Microsoft Dot NET 7 13th Sep 2004 04:09 AM
file references vs. project references for enterprise apps Adam J. Schaff Microsoft VB .NET 0 21st Aug 2003 02:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:19 AM.