473,394 Members | 2,002 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,394 software developers and data experts.

Remoting beginner: Whats missing in this code?

Jan
Yesterday I got the idea to use remoting for the test interface between our
Windows Xp Embedded - based device and our system test application.
I started looking in the MSDN help and made the code below.
My server class (RemotingServer) is located in one assembly (LibS.dll) used
by the device software and the test system will use another assembly
(LibC.dll) including my client class (TestConnectionRemoting).

We have NO security issues - the interface should be open for any
application using LibS.dll (or any other for that matter).

My immediate problem is that I get a SerilizationException when invoking a
method (the SetEventOutputInterface method call) on the remote object:
"Because of security restrictions, the type System.Runtime.Remoting.ObjRef
cannot be accessed."
- InnerException is SecurityException: "Request failed."
The next question:
I'm passing interface references to the server where one of them will be
saved in the server and used asynchronuosly later. Will I have to do any
preparation for that to work? - and can I do that?

Any help is much appreciated because remoting is not a focus area in this
project so I just have to make this test interface work so I can continue
with my other tasks. Though it is very interesting.....

Here's my code:

--------------- THE CLIENT ( LibC.dll) ---------------

class TestConnectionRemoting : MarshalByRefObject, ITestOutput, IEventOutput
{
AccessorBase m_Accessor = null;

public override bool Connect()
{
WellKnownClientTypeEntry typeentry =
new WellKnownClientTypeEntry( typeof( AccessorBase ),
"tcp://localhost:399/testinterface" );
typeentry.ApplicationUrl = "tcp://localhost:399/testinterface";
RemotingConfiguration.RegisterWellKnownClientType( typeentry );

m_Accessor = new AccessorBase();
// deliver event-output interface reference
m_Accessor.SetEventOutputInterface( (IEventOutput) this );
// call remote method where output will be sent back through the
ITestOutput interface.
m_Accessor.ExecuteCommand( (ITestOutput) this, "login developer" );

return true;
}
Sep 27 '06 #1
4 3974
Jan wrote:
Yesterday I got the idea to use remoting for the test interface between our
Windows Xp Embedded - based device and our system test application.
I started looking in the MSDN help and made the code below.
My server class (RemotingServer) is located in one assembly (LibS.dll) used
by the device software and the test system will use another assembly
(LibC.dll) including my client class (TestConnectionRemoting).

We have NO security issues - the interface should be open for any
application using LibS.dll (or any other for that matter).

My immediate problem is that I get a SerilizationException when invoking a
method (the SetEventOutputInterface method call) on the remote object:
"Because of security restrictions, the type System.Runtime.Remoting.ObjRef
cannot be accessed."
- InnerException is SecurityException: "Request failed."
In .NET by default marshaling is available only for a primitive types
You have to set Type Filtering to Full or implement ISerializable or ...
How to do this;)
It's simple just read
http://msdn.microsoft.com/library/de...etremoting.asp
--
Regards
Lukasz
Sep 27 '06 #2
Jan
Thanks alot, Lukasz. That was the clear answer to my first question. It works
perfectly. Cheers.

- but then...

I now get a RemotingException when using a passed interface in the server:
"This remoting proxy has no channel sink which means either the server has no
registered server channels that are listening, or this application has no
suitable client channel to talk to the server."

Can anybody help me on this one also?
---------------------------------------------------
FYI: My server now looks like this:
public class RemotingServer
{
private static TcpChannel m_Channel = null;
private static AccessorBase m_TestRoot = null;

public static void StartTcpAccess( int port, AccessorBase root )
{
if ( m_Channel != null )
throw new Exception( "A listener has already been started." );

BinaryServerFormatterSinkProvider provider = new
BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel = TypeFilterLevel.Full;

// Creating the IDictionary to set the port on the channel instance.
IDictionary props = new Hashtable();
props["port"] = port;

m_Channel = new TcpChannel( props, null, provider );
ChannelServices.RegisterChannel( m_Channel, false );

RemotingServices.Marshal( root, "testinterface", typeof(AccessorBase) );

m_TestRoot = root;
}
}


"Lukasz" wrote:
In .NET by default marshaling is available only for a primitive types
You have to set Type Filtering to Full or implement ISerializable or ...
How to do this;)
It's simple just read
http://msdn.microsoft.com/library/de...etremoting.asp
--
Regards
Lukasz
Sep 27 '06 #3
Jan wrote:
Thanks alot, Lukasz. That was the clear answer to my first question. It works
perfectly. Cheers.

- but then...

I now get a RemotingException when using a passed interface in the server:
"This remoting proxy has no channel sink which means either the server has no
registered server channels that are listening, or this application has no
suitable client channel to talk to the server."

Can anybody help me on this one also?
Sorry , for partial responses but i had to think about it i was working
with remoting some times ago:)
I think you have to register channel on client side too
for example like this
ChannelServices.RegisterChannel(new TcpChannel());

--
Pozdrawiam
Lukasz
Sep 27 '06 #4
Jan
Thanks again, Lukasz.

I now have it up and running.

Best regards,
Jan
FYI: The client code now looks like this:
class TestConnectionRemoting : MarshalByRefObject, ITestOutput, IEventOutput
{
AccessorBase m_Accessor = null;

public override bool Connect()
{
WellKnownClientTypeEntry typeentry =
new WellKnownClientTypeEntry( typeof( AccessorBase ),
"tcp://localhost:399/testinterface" );
typeentry.ApplicationUrl = "tcp://localhost:399/testinterface";
RemotingConfiguration.RegisterWellKnownClientType( typeentry );

BinaryClientFormatterSinkProvider sinkprovider = new
BinaryClientFormatterSinkProvider();
IDictionary properties = new Hashtable();
properties["name"] = "TcpBinary";
properties["port"] = 0;
BinaryServerFormatterSinkProvider provider = new
BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel = TypeFilterLevel.Full;

ChannelServices.RegisterChannel( new TcpChannel( properties,
sinkprovider, provider ), false );

m_Accessor = new AccessorBase();
// deliver event-output interface reference
m_Accessor.SetEventOutputInterface( (IEventOutput) this );
// call remote method where output will be sent back through the
ITestOutput interface.
m_Accessor.ExecuteCommand( (ITestOutput) this, "login developer" );

return true;
}
Sep 27 '06 #5

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

Similar topics

4
by: Steve | last post by:
I'm trying to implement this tutorial (http://www.csharphelp.com/bio/luke.html) in my code. When I build, I'm getting compiler error: error CS0234: The type or namespace name 'Tcp' does not exist...
3
by: Lucas Tam | last post by:
Does anyone have a good articles that describes the pros and cons of Web Services vs. Remoting Hosted in IIS? Is there a reason to use either or? With Remoting Hosting in IIS, is it possible...
0
by: Kirk | last post by:
I'm trying to use a Web Service to be a Remoting client of an existing ..NET 2.0 server. But I get the following error when I try to use System.Runtime.Remoting.Channels.Http in my WebService. ...
0
by: Jigar.Patel | last post by:
I have simple remoting server exposing following simple method. When I try to add webreference to this server in another project, it gives me following error: Custom tool error: Unable to import...
8
by: sandy82 | last post by:
I coded a simple example in c# In which their is a client and a server using a dll . I am confused on the Point that u have to use the .dll on both sides .Cant we have a solution of having a dll...
15
by: kydavis77 | last post by:
I am doing alot of reading and trying to teach myself how to program. I can not figure out how to make "Write a program that continually reads in numbers from the user and adds them together until...
1
by: Jan | last post by:
When I use Type.InvokeMember from my remoting server object I get a MissingMethodException: "Method '<namenot found.". My code works when the code is called normally, but not when executed from...
6
by: Palvinder Singh | last post by:
Hello google group peeps, I am new to remoting, but have a grasp of it. I am trying to create a server/client application, which will be deployed over an intranet. I have upwards of five...
0
by: =?Utf-8?B?U3RldmUgRw==?= | last post by:
I have a VB6 ActiveX exe application that uses a .Net DLL that is exposed as a COM DLL. The VB6 application is stored in ParentFolder. The .Net DLL is stored and registered in ChildFolder. I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.