473,388 Members | 1,574 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,388 software developers and data experts.

BindingList over Remoting using an interface type

This works without any problems:

Code Snippet

string uri = "tcp://localhost:8000/CAOFactory";
cf =
(CustomerInterfaces.ICAOFactory)Activator.GetObjec t(typeof(CustomerInterfaces.ICAOFactory), uri);

ICustomer objCustomer = cf.CreateCustomer();
BindingList<ICustomercustomers = objCustomer.GetCustomers();

My form has a binding source and I set its DataSource property to the
customers object. The form also has a Binding Navigator which pulls form that
BindingSource.

If I set the AllowNew property on the customers list to true I get the "+"
icon on the BindingNavigator. Exactly what I want.

However, when I click that icon it attempts to make a new object of the
interface type ICustomer. Obviously not possible.

So, I handle the AddingNew event of the list with this:

void customers_AddingNew(object sender, AddingNewEventArgs e)
{
e.NewObject = cf.CreateCustomer();
}

Sadly, that gives me the error:

"Because of security restrictions, the type System.Runtime.Remoting.ObjRef
cannot be accessed."

I've read up on this err and found that if you change the typeFilterLevel of
your remoting formatter it would work. I'd prefer not to do that.

Info on that was found here:
http://www.thinktecture.com/resource...aq/changes2003

If they changed this behavior in .Net 2.0 than it was probably for a good
reason. There has to be another way to do this? Is it not best practice to
code towards interface types? What's the solution for dynamic lists over
remoting when using interface types?

-Mike.
Jun 20 '07 #1
1 1868
The reason they did it was for security reasons. I forget the exact
reason why, but searching for that error should bring up some articles
detailing the security issues.

I think the larger issue here is that you are connecting the list and
making changes to it over remoting. It seems that you are binding the list
in the UI to objects hosted on the server, which seems very wasteful, since
every call to every method/property on any of the instances referenced by
the interfaces generated by the factory is going to result in a call back to
the server. Generally speaking, this is not a good thing for distributed
calls.

It seems like you are simply adding/editing/deleting new instances of
the type. I would recommend using a concrete, serializable type here, and
then performing the updates on the list as a whole (you would send the whole
list back with any additions, edits, and deletes in one shot to the server
to process). This would certainly get around the issue, since you would no
longer be using remotable types (at least for the items in the list).

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"MBursill" <MB******@discussions.microsoft.comwrote in message
news:06**********************************@microsof t.com...
This works without any problems:

Code Snippet

string uri = "tcp://localhost:8000/CAOFactory";
cf =
(CustomerInterfaces.ICAOFactory)Activator.GetObjec t(typeof(CustomerInterfaces.ICAOFactory),
uri);

ICustomer objCustomer = cf.CreateCustomer();
BindingList<ICustomercustomers = objCustomer.GetCustomers();

My form has a binding source and I set its DataSource property to the
customers object. The form also has a Binding Navigator which pulls form
that
BindingSource.

If I set the AllowNew property on the customers list to true I get the "+"
icon on the BindingNavigator. Exactly what I want.

However, when I click that icon it attempts to make a new object of the
interface type ICustomer. Obviously not possible.

So, I handle the AddingNew event of the list with this:

void customers_AddingNew(object sender, AddingNewEventArgs e)
{
e.NewObject = cf.CreateCustomer();
}

Sadly, that gives me the error:

"Because of security restrictions, the type System.Runtime.Remoting.ObjRef
cannot be accessed."

I've read up on this err and found that if you change the typeFilterLevel
of
your remoting formatter it would work. I'd prefer not to do that.

Info on that was found here:
http://www.thinktecture.com/resource...aq/changes2003

If they changed this behavior in .Net 2.0 than it was probably for a good
reason. There has to be another way to do this? Is it not best practice to
code towards interface types? What's the solution for dynamic lists over
remoting when using interface types?

-Mike.

Jun 20 '07 #2

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

Similar topics

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"...
6
by: Catherine Jones | last post by:
Hi all, we need urgent help in a matter. We are trying to pass a COM object from the client to server and are facing some problems in the same. We've our client in C# as well as the Server...
6
by: Uttam | last post by:
Hello, We are at a very crucial decision making stage to select between .Net and Java. Our requirement is to download a class at runtime on the client computer and execute it using remoting or...
5
by: Mark Overstreet | last post by:
I am writing an app that needs to contain an object model that allows it to be controlled similiar to something like Word. However, I am writing this in C# and all managed code. I know that I can...
4
by: Uchiha Jax | last post by:
Hello everyone, I am a plenty silly person who is trying to learn .NET remoting through trial and error (all articles I read are going over my head at the moment (mostly) so I thought i'd give...
2
by: matthew_glen_evans | last post by:
Hi there, Quick one about interfaces in c#. It seems that it is illegal to declare types within an interface. I was quite used to doing this in VB.net where the interface can define a...
4
by: Rich | last post by:
Can anyone suggest a good (current) tutorial on how to do basic remoting with C# (2005 express edition)?
8
by: schaf | last post by:
Hi Ng! My application (version 1 a1) communicates with a service (version 1 s1). Now I would like to update the service and create a service version 2 (s2). The new function calls within s2 are...
2
by: erbilkonuk | last post by:
Hi, I am very new to .NET Remoting and I try to run a simple program to subscribe to an event raised by Remoting Class. The Remoting Server initiates an instance of Remoting Class as Singleton /...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.