473,785 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tiers and Circular References

I want middletier objects and data access objects in different namespaces.

I want the middle tier object to get a reference to the data access object
and pass itself as a parameter to the data access object's constructor,
accordingly the constructor of the data access object must declare a datatype
of the Middle tier object.

The Middle Tier declares a project reference to the Data Access Project to
create the Data Access Object.

When I try to establish a similar reference to the Middle Tier within the
Data Access Project, I get " A reference to Middle Tier could not be added.
Adding this project as a reference would cause a circular dependency."

TIA, doyle

Sep 29 '05 #1
1 4962
Doyle wrote:
I want middletier objects and data access objects in different namespaces.
No problem.
I want the middle tier object to get a reference to the data access object
and pass itself as a parameter to the data access object's constructor,
accordingly the constructor of the data access object must declare a
datatype
of the Middle tier object.

The Middle Tier declares a project reference to the Data Access Project to
create the Data Access Object.
Ah, now you're talking two separate assemblies, in addition to separate
namespaces.
When I try to establish a similar reference to the Middle Tier within the
Data Access Project, I get " A reference to Middle Tier could not be added.
Adding this project as a reference would cause a circular dependency."


Right, obviously. This is not possible. You should rearrange your classes
in the assemblies (or even merge them) so that dependencies all work "in
one direction".

I don't feel I know enough about your specific situation, but a common
solution in similar situations would be to have the data access class and
a base class for the middle tier object in one assembly and let the data
access class work only with the base class. Then the middle tier class
could be in a different assembly, derived from the base class, and the
directions or dependencies would be fine. Like this:

Classes in assembly "data":

class DataAccessObjec t {
public DataAccessObjec t(MiddleTierObj ect middleTierObjec t) {
// do something
}
}

// Maybe this would even be an interface only? And in the real
// world, it might not be called MiddleTierObjec t because the
// data assembly really doesn't know or care about any middle
// tier. Just to make things clear here.
abstract class MiddleTierObjec t {
}

Classes in assembly "middletier ":

class MyConcreteMiddl eTierObject : MiddleTierObjec t {
}
Oliver Sturm
--
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)
Sep 30 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
7984
by: Earth Worm Jim | last post by:
I have been able to get simple circular references to be serialized in xml by using the ImportTypeMapping method on the SoapReflectionImporter class. But I am unable to serialise circular references when the circular reference is contained with in a collection class, specifically I am using a custom ArrayList object. I keep getting a StackOverFlow Exception from the XmlSerializer class when attempting the serialisation. The classes...
12
7064
by: Frank Rizzo | last post by:
I have a circular reference between 2 classes in the same project (i.e. each class refers to the other). The app runs fine and I am seeing no issues, which kind of surprised me. Are there any issues that I am not seeing (performance wise or garbage collection wise) with circular references? Thanks.
5
6852
by: Gos | last post by:
Hi, It is known that .NET does not allow us to add circular references. Is there a way to workaround this problem by late-binding the objects at run time? Will this create any other problems? One solution to the problem is to re-architect the solution. But, I dont want to do this as there are many modules in the project which are already developed and nearing the release.
6
5081
by: Stephen Robertson | last post by:
We are currently in a dead end with a circular reference issue using vb.net, and are hoping someone might help us resolve it. Idea... We have frmmain calling frmperson (dim f as new frmperson) in search (no record) mode. When the search is executed, frmperson calls frmsearchresult (dim f as new frmsearchresult) which is a listing of persons. From frmsearchresults, frmperson is called (dim f as new frmperson) with the resulting...
1
241
by: Doyle | last post by:
I want middletier objects and data access objects in different namespaces. I want the middle tier object to get a reference to the data access object and pass itself as a parameter to the data access object's constructor, accordingly the constructor of the data access object must declare a datatype of the Middle tier object. The Middle Tier declares a project reference to the Data Access Project to create the Data Access Object.
2
2825
by: Lapu-Lapu | last post by:
I have authored a web service using ASP 2.0. The web services return objects that use generics and that also contain circular references. Programmatically, everything works well, as long as you use the web service proxy client generated by visual studio. However, the default test harness provided by the .asmx file errors out because it seems to use XmlSerialization and cannot handle circular references. I understand that the...
5
3803
by: Madhur | last post by:
Hello If I define two classes in the same cs file. And in each class, I define the object of other class as a member. Can anyone explain me how .NET or its compiler will resolve this kind of reference since one class would not be compiled unless other is compiled. This is kind of a deadlock. Isnt it ?
3
2927
by: =?Utf-8?B?UGF1bCBIYWxl?= | last post by:
Moving all User Controls to a single directory has solved my problem - Thanks Eliyahu. That said, I still got one Circular ref error yesterday, rebuilt again and the build was fine? Far far better than the amount of errors I was originally getting on builds before I consilidated by UC's though :-) "Paul Hale" wrote:
2
1859
by: Dansk | last post by:
Hi all, I am currently writing some code that explores assemblies dependencies. I start loading the first assembly with Assmebly.LoadFrom which gives me an Assembly instance. Then, I enumerate the AssemblyNames from the GetReferencedAssemblies() collection.
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10087
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.