Print Page | Close Window

Silverlight - Cannot Coerce

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2376
Printed Date: 01-Feb-2026 at 11:29pm


Topic: Silverlight - Cannot Coerce
Posted By: jipock
Subject: Silverlight - Cannot Coerce
Date Posted: 14-Dec-2010 at 1:50pm
Good Evening,
 
I'm trying to edit an entity that I've created and am getting a "Cannot Coerce...." error.
 
Specifically,I have an object (say, a car) that contains an object (Engine). I'm loading this from the database without any errors. But, I want to 'click a button and select a new engine from a child window and put this selected engine into the engine property of the car (and essentially removing the original engine).  My code looks like this:
 

if (box.DialogResult == true){

_model.CurrentCar.EngineId = box.SelectedEngine.EngineID;

_model.CurrentCar.Engine = box.SelectedEngine; }

To confirm - the Engine and Selected Engine are the same IdeaBlade entity object type (just different instantiations).
 
The Error message is: "Unable to construct a PropertyInterceptorAction for method: BeforeSetAnyProperty' in type 'Namespace.Engine' Cannot coerce IdeaBlade.EntityeModel.NavigationEntityPropertySetInterceptorsArgs..."
 
 
Any suggestions where to look for an answer?



Replies:
Posted By: kimj
Date Posted: 17-Dec-2010 at 7:23pm
The arguments to the BeforeSetAnyProperty property interceptor need to be less specific.  Since the interceptor will be called before setting any property on the entity, the arguments need to be suitable for any property type.  There are a number of different arguments which will work, a few would be:
 
  BeforeSetAnyProperty(IPropertyInterceptorArgs args)
 
  BeforeSetAnyProperty(PropertyInterceptorArgs<Engine, object> args)
 
Check out the BeforeSetAttribute in the DevForce Help Reference installed with the product for more possibilities.


Posted By: jipock
Date Posted: 20-Dec-2010 at 6:47am

(Hitting myself on the head at the answer)... 

It's working now. Thank you!
 
 
 
 



Print Page | Close Window