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.