473,695 Members | 1,634 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Remoting and circular dependencies

I have written a windows service and want to expose a web based user
interface for this service. I then wrote a class library containing a
..net remoting server. The class library have a method named
StartRemotingSe rver(). To be able to call this method from the windows
service I need to reference the remoting class library, but for the
class library to be able to access the internal structures of the
windows service the class library needs to reference the windows
service. Since circular dependecies is not allowed this does not work.
Some of you may tell me there is something wrong with my design,
because circular dependencies should not be necessary, but please give
me an advice on how to change my design. I have head that one method to
resolve circular dependencies is to use reflection. Can anyone show me
some example code to resolve circular dependecies using reflection?

Thank you!

Dec 2 '06 #1
8 4139
I think you've hit the nail on the head, it certainly sounds like a
design issue. I need a little more detail though. What in the service
does the remoting library require? Could you perhaps resolve the
dependency by creating a new class in the remoting library that the
host can populate with session data and that can raise events, that
sort of thing?
ny***********@g mail.com wrote:
I have written a windows service and want to expose a web based user
interface for this service. I then wrote a class library containing a
.net remoting server. The class library have a method named
StartRemotingSe rver(). To be able to call this method from the windows
service I need to reference the remoting class library, but for the
class library to be able to access the internal structures of the
windows service the class library needs to reference the windows
service. Since circular dependecies is not allowed this does not work.
Some of you may tell me there is something wrong with my design,
because circular dependencies should not be necessary, but please give
me an advice on how to change my design. I have head that one method to
resolve circular dependencies is to use reflection. Can anyone show me
some example code to resolve circular dependecies using reflection?

Thank you!
Dec 2 '06 #2
Hi,

You could place the "internal structures" in another library project. Each
of the two assemblies can reference it.

Normally, the library is the third project since it doesn't provide a
graphical interface. Then, the interface is provided by a WinForms or
ASP.NET application that can reference the library. Four assemblies isn't
required to alleviate the circular dependency, so I'd be curious to your
design as well if you think you'll need another project, but I wouldn't
count that out just yet.

--
Dave Sexton

<ny***********@ gmail.comwrote in message
news:11******** **************@ 80g2000cwy.goog legroups.com...
>I have written a windows service and want to expose a web based user
interface for this service. I then wrote a class library containing a
.net remoting server. The class library have a method named
StartRemotingSe rver(). To be able to call this method from the windows
service I need to reference the remoting class library, but for the
class library to be able to access the internal structures of the
windows service the class library needs to reference the windows
service. Since circular dependecies is not allowed this does not work.
Some of you may tell me there is something wrong with my design,
because circular dependencies should not be necessary, but please give
me an advice on how to change my design. I have head that one method to
resolve circular dependencies is to use reflection. Can anyone show me
some example code to resolve circular dependecies using reflection?

Thank you!

Dec 3 '06 #3
The service is controlling some robots. They are moving very fast and
the windows service keeps track of where they are, and avoids
collisions. I want to create a web-page where you can see all the robot
positions. To make this possible i make a remoting service whit one
method GetRobotPositio n(int robotNo). This method is calling a similar
method in the windows service to get the position of the robot. The web
page, which is a seperate project, is connecting to the remoting server
and calls GetRobotPositio n. The remoting server needs to know about the
windows service to get the position of the robots, and the windows
service need to know about the remoting server to be able to start/stop
it. Can someone give me a concrete example on how to solve this. I want
my code to be easy to read. Maybe the simplest solution is just to
merge the windows service and the remoting server into one assembly,
but I don't want to do that as it shouldn't be necessary. If anyone can
show me how to solve this using reflection i would be very happy.

Thank you!

DeveloperX skrev:
I think you've hit the nail on the head, it certainly sounds like a
design issue. I need a little more detail though. What in the service
does the remoting library require? Could you perhaps resolve the
dependency by creating a new class in the remoting library that the
host can populate with session d<<ata and that can raise events, that
sort of thing?

Dec 3 '06 #4
Hi,

You don't need to use Reflection.

If you don't want the Remoting server in the Windows Service Project
(simplest approach), then you can create another project that contains the
actual Windows Service implementation:

Windows Service Project
References: RobotsService Project (new)
References: Remoting Project

class Service : ServiceBase
{
private RobotsService robotsService;
private RemoteServer remotingServer;

protected override void OnStart(string[] args)
{
robotsService = new RobotsService() ;
robotsService.S tart();

// TODO: remoting config
remotingServer = new RemoteServer();
remotingServer. Start(robotsSer vice);
}
}
Remoting Project
References: RobotsService Project (new)

public class RemoteServer : MarshalByRefObj ect
{
private RobotsService service;

public void Start(RobotsSer vice service)
{
this.service = service;
}

public Point GetRobotPositio n(int robotNo)
{
return service.GetRobo tPosition(robot No);
}
}
RobotsService Project (new project)
References: None

public class RobotsService
{
public void Start()
{
// actual service implementation
}

public Point GetRobotPositio n(int robotNo)
{
return Point.Empty;
}
}

--
Dave Sexton

<ny***********@ gmail.comwrote in message
news:11******** **************@ f1g2000cwa.goog legroups.com...
The service is controlling some robots. They are moving very fast and
the windows service keeps track of where they are, and avoids
collisions. I want to create a web-page where you can see all the robot
positions. To make this possible i make a remoting service whit one
method GetRobotPositio n(int robotNo). This method is calling a similar
method in the windows service to get the position of the robot. The web
page, which is a seperate project, is connecting to the remoting server
and calls GetRobotPositio n. The remoting server needs to know about the
windows service to get the position of the robots, and the windows
service need to know about the remoting server to be able to start/stop
it. Can someone give me a concrete example on how to solve this. I want
my code to be easy to read. Maybe the simplest solution is just to
merge the windows service and the remoting server into one assembly,
but I don't want to do that as it shouldn't be necessary. If anyone can
show me how to solve this using reflection i would be very happy.

Thank you!

DeveloperX skrev:
>I think you've hit the nail on the head, it certainly sounds like a
design issue. I need a little more detail though. What in the service
does the remoting library require? Could you perhaps resolve the
dependency by creating a new class in the remoting library that the
host can populate with session d<<ata and that can raise events, that
sort of thing?


Dec 3 '06 #5
ny***********@g mail.com wrote:
>The service is controlling some robots. They are moving very fast and
the windows service keeps track of where they are, and avoids
collisions. I want to create a web-page where you can see all the robot
positions.
Just a brief pointer in case you didn't know... the Microsoft Robotics
SDK is out (as a Community Tech Preview). It has a .net API and lots
of c# examples. And it uses web-pages to monitor your robots. Might be
fun.

http://msdn.microsoft.com/robotics/

--
Lucian
Dec 3 '06 #6
Has anyone built a Terminator or Robocop yet?

- just wondering how far along we are ;)

--
Dave Sexton

"Lucian Wischik" <lu***@wischik. comwrote in message
news:q7******** *************** *********@4ax.c om...
ny***********@g mail.com wrote:
>>The service is controlling some robots. They are moving very fast and
the windows service keeps track of where they are, and avoids
collisions. I want to create a web-page where you can see all the robot
positions.

Just a brief pointer in case you didn't know... the Microsoft Robotics
SDK is out (as a Community Tech Preview). It has a .net API and lots
of c# examples. And it uses web-pages to monitor your robots. Might be
fun.

http://msdn.microsoft.com/robotics/

--
Lucian

Dec 3 '06 #7
Thank you Dave! Very well explained. I'll try this aproach.
Dave Sexton wrote:
Hi,

You don't need to use Reflection.

If you don't want the Remoting server in the Windows Service Project
(simplest approach), then you can create another project that contains the
actual Windows Service implementation:

Windows Service Project
References: RobotsService Project (new)
References: Remoting Project

class Service : ServiceBase
{
private RobotsService robotsService;
private RemoteServer remotingServer;

protected override void OnStart(string[] args)
{
robotsService = new RobotsService() ;
robotsService.S tart();

// TODO: remoting config
remotingServer = new RemoteServer();
remotingServer. Start(robotsSer vice);
}
}
Remoting Project
References: RobotsService Project (new)

public class RemoteServer : MarshalByRefObj ect
{
private RobotsService service;

public void Start(RobotsSer vice service)
{
this.service = service;
}

public Point GetRobotPositio n(int robotNo)
{
return service.GetRobo tPosition(robot No);
}
}
RobotsService Project (new project)
References: None

public class RobotsService
{
public void Start()
{
// actual service implementation
}

public Point GetRobotPositio n(int robotNo)
{
return Point.Empty;
}
}

--
Dave Sexton

<ny***********@ gmail.comwrote in message
news:11******** **************@ f1g2000cwa.goog legroups.com...
The service is controlling some robots. They are moving very fast and
the windows service keeps track of where they are, and avoids
collisions. I want to create a web-page where you can see all the robot
positions. To make this possible i make a remoting service whit one
method GetRobotPositio n(int robotNo). This method is calling a similar
method in the windows service to get the position of the robot. The web
page, which is a seperate project, is connecting to the remoting server
and calls GetRobotPositio n. The remoting server needs to know about the
windows service to get the position of the robots, and the windows
service need to know about the remoting server to be able to start/stop
it. Can someone give me a concrete example on how to solve this. I want
my code to be easy to read. Maybe the simplest solution is just to
merge the windows service and the remoting server into one assembly,
but I don't want to do that as it shouldn't be necessary. If anyone can
show me how to solve this using reflection i would be very happy.

Thank you!

DeveloperX skrev:
I think you've hit the nail on the head, it certainly sounds like a
design issue. I need a little more detail though. What in the service
does the remoting library require? Could you perhaps resolve the
dependency by creating a new class in the remoting library that the
host can populate with session d<<ata and that can raise events, that
sort of thing?

Dec 3 '06 #8
On 2 Dec 2006 12:42:16 -0800, ny***********@g mail.com wrote:
I have written a windows service and want to expose a web based user
interface for this service. I then wrote a class library containing a
.net remoting server. The class library have a method named
StartRemotingSe rver(). To be able to call this method from the windows
service I need to reference the remoting class library, but for the
class library to be able to access the internal structures of the
windows service the class library needs to reference the windows
service. Since circular dependecies is not allowed this does not work.
Some of you may tell me there is something wrong with my design,
because circular dependencies should not be necessary, but please give
me an advice on how to change my design. I have head that one method to
resolve circular dependencies is to use reflection. Can anyone show me
some example code to resolve circular dependecies using reflection?

Thank you!
Interesting approach you have there ... Question: is it possible to
abstract the logic causing the circular reference to another assembly?
--
Bits.Bytes
http://bytes.thinkersroom.com
Dec 3 '06 #9

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

Similar topics

12
5248
by: jinal jhaveri | last post by:
Hi All, I have one question regarding circular inheritance I have 3 files 1) A.py , having module A and some other modules 2) B.py having module B and some other modules 3) C.py having module C and some other modules
8
2053
by: Tim Tyler | last post by:
Like C, Python seems to insist I declare functions before calling them - rather than, say, scanning to the end of the current script when it can't immediately find what function I'm referring to. C lets you predeclare functions to allow for the existence of functions with circular dependencies. Does Python allow you to do something similar? If not how do you create functions with circular dependencies in
1
2094
by: Henry Miller | last post by:
I have the following code (much simplified for this post). Note that SessionKey uses DataAccess, and DataAccess requires SessionKey in it's constructor. Public Class SessionKey Public IsValidSession as Boolean Sub New(UserName, Password) ' Create session, including calls on DataAccess ' to validate username/password
15
3986
by: anders | last post by:
Hi! I have a config file that looks like this: <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.runtime.remoting> <application> <service> <wellknown mode="SingleCall" type="Interfaces, IMyFirstRemotableObj" objectUri="ControlCenter" /> </service>
2
3102
by: ernesto basc?n pantoja | last post by:
Hi everybody: I'm implementing a general C++ framework and I have a basic question about circular dependencies: I am creating a base class Object, my Object class has a method defined as: virtual String toString(); where String is defined as:
3
2898
by: Keith F. | last post by:
Visual Studio doesn't allow circular references between projects. I have a situation where I need to allow 2 projects to reference each other. Is there any way to make Visual Studio allow this? I realize the best way is to restructure the solution so the circular reference isn't necessary, which I intend to do. But at the moment, I'm looking for a quicker work-around if there is one. Thanks.... Keith F.
7
13514
by: barias | last post by:
Although circular dependencies are something developers should normally avoid, unfortunately they are very easy to create accidentally between classes in a VS project (i.e. circular compile-time dependencies). But then I started wondering how "easy" it would be to similarly make a NON-RUNTIME circular dependency between (implicitly linked) DLLs. Indeed authors like John Lakos, who focus on compile/link-time dependencies (not run-time),...
5
3395
by: =?Utf-8?B?Qm9i?= | last post by:
I have a table of dependencies and want to check to see if the dependencies cause a circular reference. Any sugesstions on how to do this using c#. Example, ID DependsOnID 1 2 1 4 2 3 3 1 (circular reference)
6
3468
by: Mosfet | last post by:
Hi, I have two classes, let's call them class A and class B with mutual dependencies as shown below and where implementation is inside .h (no cpp) #include "classB.h" class A {
0
8565
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
9113
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
8839
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
7656
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6488
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5837
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
4339
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
4577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
1971
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.