Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Remoting / March 2004

Tip: Looking for answers? Try searching our database.

Remoting a Reflected Object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Livingston George - 24 Mar 2004 17:40 GMT
Hi,

I am trying to Publish a Reflected Object (REFOBJ) and access its method
from a remote machine.

The REFOBJ is inherited from an abstract class which exists on both client
and the server machines.

I Load the REFOBJ Assembly using Assembly.LoadFile() method and hold it in a
global variable in my Application.

The REFOBJ has a method "Publish" which will Publish itself on the given
port and Name. I am calling this method after I Load the Assembly file.

But When I try to access the object from a client, I get an error, "No
connection could be made because the target machine actively refused it."

I tried the same thing without using Reflection, it is working fine.

Is it possible for Remoting a Reflected Object by any chance???
I also tried using Reflection's InvokeMember

But I get an error "Cannot create an abstract class". I believe, when I try
to build the target object for reflection, it requires the object at the
client's process which is not available here.

Thanks,

Regards,
Livingston.
Allen Anderson - 24 Mar 2004 19:10 GMT
are you sure you mean reflection and not reference object?  If you are
having trouble creating your object from the shared assembly, check
out this article.  If you still have problems, just ask and I'll try
to answer as best I can.

http://www.glacialcomponents.com/ArticleDetail.aspx?articleID=RemoteObject

Allen Anderson
http://www.glacialcomponents.com
mailto: allen@put my website url here.com

>Hi,
>
[quoted text clipped - 26 lines]
>Regards,
>Livingston.
Livingston George - 24 Mar 2004 20:02 GMT
Allen,

Thanks for the fast reply.

I have to use Publish a Reflection object only.

I have been going through your articles for sometime now.
I used your method of implementing Remoting.

My code is very similar to yours except that,
the Implementation of the ShareDll Abstract classes in kept in a Dll which
has to get loaded via Reflection.

I have a Windows Service/Application which will load this dll and it will
create an instance of the publishing object and call the publish() method on
that object so that it can publish itself.

I tried this using a Windows application where the publishing looked fine. I
dont know if publishing will ever throw any kind of exception on an error.

The Reflected object type is clearly visible when it is getting published.

But the client module just gets the same error,
"No connection can be made.."

Thanks,
Livingston.

> are you sure you mean reflection and not reference object?  If you are
> having trouble creating your object from the shared assembly, check
[quoted text clipped - 37 lines]
> >Regards,
> >Livingston.
Allen Anderson - 24 Mar 2004 21:03 GMT
why exactly are you trying to use a refelcted object to proxy to?  I
guess I don't quite get what your trying to accomplish.  Maybe I could
better assist you if I could find out what the end result is you are
trying tog et to.

Allen Anderson
http://www.glacialcomponents.com
mailto: allen@put my website url here.com

>Allen,
>
[quoted text clipped - 23 lines]
>Thanks,
>Livingston.
Livingston George - 24 Mar 2004 22:30 GMT
Allen,

I have 2 Components / assemblies. a. MainModule. and b.DataServerModule.

DataServerModule is referring to MainModule. And main module should not be
dependent on DataServerModule. Reason is, DataServerModule can be replaced
by another module in the future.
But the DataServerModule should be dynamically callable by MainModule.
The DataServerModule has classes implementing few Interfaces. On these
interfaces the MainModule will make method calls.

The DataServerModule is also implementing a Callback Interface Object which
will be used by remote clients to send data by calling methods on it.
For this I need to publish the Callback Object.

This is the Scenario.

First I was planning to Host both Modules in separate applications so that I
can achieve the MainModule's independency but the DataServerModule again had
to have an access to MainModule and its objects. So I could not move these
two assemblies to two different processes. If I do then it means, More
remoting objects on both the assemblies. More metadata dlls (like your
ShareDLL).

So, I was trying to use reflection to get the DataServerModule loaded.
I was assuming if the publishing is done by the Callback Object itself, the
MainModule is totally independent of handling DataServerModule.

Without using Reflection publishing from the object itself works fine. But
when I do the same looks like Publishing fails.

I think now you have a good idea of what I am trying to achieve.

Thanks,
Livingston.

> why exactly are you trying to use a refelcted object to proxy to?  I
> guess I don't quite get what your trying to accomplish.  Maybe I could
[quoted text clipped - 32 lines]
> >Thanks,
> >Livingston.
Allen Anderson - 25 Mar 2004 16:58 GMT
yes, I understand what your trying to get to now.  That's a tough call
though.

I did something similar where I wanted to be able to upgrade the
object and I used an interface instead of an abstract class.  This
gave me the looser type checking but still allowed me to dynamically
replace the files without it screaming at me about incorrect versions
of objects.

Allen Anderson
http://www.glacialcomponents.com
mailto: allen@put my website url here.com

>Allen,
>
[quoted text clipped - 31 lines]
>Thanks,
>Livingston.
Livingston George - 26 Mar 2004 16:31 GMT
Allen,

Can I know how you achieved this?

I mean, Can I see some code?
I wonder how the Server Application instanciates the Reflected object!

I initially, had my ShareDll classes has Interfaces only.
But, an Interface cannot be inherited from MarshalByRefObj rite?
So I could not use it.

But May be I should inherit the Implementation class from MarshalByRefObj
and Implement my ShareDll.

Thanks,
Livingston.

> yes, I understand what your trying to get to now.  That's a tough call
> though.
[quoted text clipped - 44 lines]
> >Thanks,
> >Livingston.
Tom Hall - 27 Mar 2004 03:33 GMT
Well, actually you can use interfaces - its just tricky to create the object
(fortunately Ingo Rammer has solved it)!

Check out this article - I have use his technique extensively in my
projects - it works.

http://www.ingorammer.com/RemotingFAQ/USEINTERFACESWITHCONFIGFILES.html

Tom

> Allen,
>
[quoted text clipped - 69 lines]
> > >Thanks,
> > >Livingston.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.