473,387 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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
StartRemotingServer(). 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 4108
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***********@gmail.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
StartRemotingServer(). 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.googlegro ups.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
StartRemotingServer(). 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 GetRobotPosition(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 GetRobotPosition. 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.Start();

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

public class RemoteServer : MarshalByRefObject
{
private RobotsService service;

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

public Point GetRobotPosition(int robotNo)
{
return service.GetRobotPosition(robotNo);
}
}
RobotsService Project (new project)
References: None

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

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

--
Dave Sexton

<ny***********@gmail.comwrote in message
news:11**********************@f1g2000cwa.googlegro ups.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 GetRobotPosition(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 GetRobotPosition. 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***********@gmail.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.com...
ny***********@gmail.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.Start();

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

public class RemoteServer : MarshalByRefObject
{
private RobotsService service;

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

public Point GetRobotPosition(int robotNo)
{
return service.GetRobotPosition(robotNo);
}
}
RobotsService Project (new project)
References: None

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

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

--
Dave Sexton

<ny***********@gmail.comwrote in message
news:11**********************@f1g2000cwa.googlegro ups.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 GetRobotPosition(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 GetRobotPosition. 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***********@gmail.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
StartRemotingServer(). 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
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...
8
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. ...
1
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...
15
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"...
2
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:...
3
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? ...
7
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...
5
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 ...
6
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.