<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Property Interceptor prevents design time entity creation</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Property Interceptor prevents design time entity creation</description>
  <pubDate>Wed, 13 May 2026 03:48:41 -700</pubDate>
  <lastBuildDate>Wed, 05 Sep 2012 11:15:58 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=3604</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Property Interceptor prevents design time entity creation : Very good point Marcel, will never...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3604&amp;PID=14351#14351</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=579" rel="nofollow">gregweb</a><br /><strong>Subject:</strong> 3604<br /><strong>Posted:</strong> 05-Sep-2012 at 11:15am<br /><br />Very good point Marcel, will never do that again!]]>
   </description>
   <pubDate>Wed, 05 Sep 2012 11:15:58 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3604&amp;PID=14351#14351</guid>
  </item> 
  <item>
   <title>Property Interceptor prevents design time entity creation : Greg, Code in the constructor...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3604&amp;PID=14349#14349</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1005" rel="nofollow">mgood</a><br /><strong>Subject:</strong> 3604<br /><strong>Posted:</strong> 05-Sep-2012 at 10:45am<br /><br /><P>Greg,</P><DIV>Code in the constructor is an anti-pattern that gets you in trouble as it just did. All a constructor should do is initialize the private fields and make sure the object is in a valid state. Initializing properties and calling methods should be done from other methods. Avoid getting/setting properties in the constructor. Getting or setting a property is an innocent looking method call, the setter/getter of the property. The setter/getter can do any number of things that will fail if the object isn't fully constructed yet, which is the case if the setter is called from within a constructor, and what happened in your case. </DIV><DIV>&nbsp;</DIV><DIV>The safe way to create and initialize an Entity is by means of a factory method. Following is a simple example.</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">class</SPAN> StaffingResource : AuditEntityBase<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">internal</SPAN> StaffingResource()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">static</SPAN> StaffingResource Create()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: blue">new</SPAN> StaffingResource { Id = CombGuid.NewGuid() };<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; }<BR></DIV>]]>
   </description>
   <pubDate>Wed, 05 Sep 2012 10:45:50 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3604&amp;PID=14349#14349</guid>
  </item> 
  <item>
   <title>Property Interceptor prevents design time entity creation : An error was being thrown on this...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3604&amp;PID=14344#14344</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=579" rel="nofollow">gregweb</a><br /><strong>Subject:</strong> 3604<br /><strong>Posted:</strong> 05-Sep-2012 at 6:29am<br /><br />An error was being thrown on this line:<br />if(args.Instance.CompletedOn == null)...<br /><br />The error was "Object Reference not set to instance of object" which makes no sense as it was a null check.  The debugger showed the CompletedOn property was null.<br /><br />In any case, I think the issue was that the AfterSet was being run during the object initialization so the object wasn't fully initialized.  As soon as I set the property after the initialization, then it stopped throwing the error.<br /><br />I tried recreating the issue in the sample issue to no avail, but at least it is working as expected now.<br /><br />Thanks for the support!<br /><br />Greg ]]>
   </description>
   <pubDate>Wed, 05 Sep 2012 06:29:32 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3604&amp;PID=14344#14344</guid>
  </item> 
  <item>
   <title>Property Interceptor prevents design time entity creation : Can you tell what exception, if...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3604&amp;PID=14333#14333</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 3604<br /><strong>Posted:</strong> 04-Sep-2012 at 7:27pm<br /><br />Can you tell what exception, if any, it is throwing on that piece of code?]]>
   </description>
   <pubDate>Tue, 04 Sep 2012 19:27:30 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3604&amp;PID=14333#14333</guid>
  </item> 
  <item>
   <title>Property Interceptor prevents design time entity creation : Hi Denis, Thanks very much for...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3604&amp;PID=14332#14332</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=579" rel="nofollow">gregweb</a><br /><strong>Subject:</strong> 3604<br /><strong>Posted:</strong> 04-Sep-2012 at 6:04pm<br /><br />Hi Denis, Thanks very much for the sample.<br /><br />The issue seemed to narrow down to the following code in the Interceptor:<br />if(args.Instance.CompletedOn == null)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; args.Instance.CompletedOn = DateTime.UtcNow.ToLocalTime();<br /><br />In any case, if I put in a designer check to not run the code at design time, then everything works fine.<br /><br />Also, if I use OnPropertyChanged() instead of the interceptor, it also works just fine.<br /><br />Also, VS2010 seems to show the designer more reliably - ie the same code in 12 does not show the designer, while opening it in 10 does. Then going back to 12 it does open propertly.  Go figure! <br /><br />Greg<span style="font-size:10px"><br /><br />Edited by gregweb - 05-Sep-2012 at 4:25am</span>]]>
   </description>
   <pubDate>Tue, 04 Sep 2012 18:04:03 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3604&amp;PID=14332#14332</guid>
  </item> 
  <item>
   <title>Property Interceptor prevents design time entity creation :   Hi Greg,I added the 2 items...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3604&amp;PID=14329#14329</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 3604<br /><strong>Posted:</strong> 04-Sep-2012 at 2:33pm<br /><br /><div>Hi Greg,</div><div><br></div><div>I added the 2 items (PropertyInterceptor and RelatedEntityList) above to my design time data sample solution and didn't encounter any issue.&nbsp;</div><div><br></div><div>In the PropertyInterceptor case, I have both AfterSet and AfterGet, and I can see the AfterGet being applied and invoked.</div><div><br></div><div>Same thing with the RelatedEntityList. I have Customer and Orders and I can see my Orders mock data on the data grid.</div><div><br></div><div>One suggestion is to debug your design time data invocation when you bring your XAML up in the designer mode. You can do this by bringing up another copy of your solution and attach this solution to the other using Debug - Attach to Process. You can then put breakpoints and see what's going on.</div><div><br></div><div>I've attached my sample solution here. I'm using DevForce 6.1.8.1 and SL4.</div><div><br></div><div><a href="uploads/912/DevForceWithMvvmLight.zip" target="_blank">uploads/912/DevForceWithMvvmLight.zip</a><br></div><div><br></div><div>If you're using SL5, please note that we have encountered known issues with design time data when SL5 is installed. Here's a couple of links that have more info.</div><div><br></div><div><a href="http://drc.ideablade.com/xwiki/bin/view/&#068;ocumentati&#111;n/code-samples-silverlight-5-beta#HKnownissues" target="_blank">http://drc.ideablade.com/xwiki/bin/view/Documentation/code-samples-silverlight-5-beta#HKnownissues</a></div><div><br></div><div><a href="http://www.ideablade.com/forum/forum_posts.asp?TID=3247&amp;title=designtime-problem" target="_blank">http://www.ideablade.com/forum/forum_posts.asp?TID=3247&amp;title=designtime-problem</a></div><div><br></div><div>Please let me know if I'm missing anything.</div><span style="font-size:10px"><br /><br />Edited by DenisK - 04-Sep-2012 at 2:36pm</span>]]>
   </description>
   <pubDate>Tue, 04 Sep 2012 14:33:33 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3604&amp;PID=14329#14329</guid>
  </item> 
  <item>
   <title>Property Interceptor prevents design time entity creation : Another issue along this line...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3604&amp;PID=14325#14325</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=579" rel="nofollow">gregweb</a><br /><strong>Subject:</strong> 3604<br /><strong>Posted:</strong> 04-Sep-2012 at 9:34am<br /><br />Another issue along this line is that the RelatedEntityList&lt;T&gt; type is  not design time creatable.<br /><br />This means that if you have a UI with entity fields, and a grid for related items, the related items will not show in the grid at design time.]]>
   </description>
   <pubDate>Tue, 04 Sep 2012 09:34:17 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3604&amp;PID=14325#14325</guid>
  </item> 
  <item>
   <title>Property Interceptor prevents design time entity creation : I am using a Property Interceptor...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3604&amp;PID=14314#14314</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=579" rel="nofollow">gregweb</a><br /><strong>Subject:</strong> 3604<br /><strong>Posted:</strong> 03-Sep-2012 at 4:41pm<br /><br />I am using a Property Interceptor in a partial entity class and it works fine at run time:<br /><br />&#091;AfterSet(EntityPropertyNames.PercentComplete)&#093;<br />MethodGoesHere...<br /><br />However, in Visual Studio, the Entity can no longer be created by the designer and so I can't use design time data.  (ie, it is no longer Blendable).<br /><br />If I comment out the attribute, it becomes Blendable again.<br /><br />Any suggestions on this?  I really like binding to test data at design time as it makes UI design much faster.<br /><br />Greg]]>
   </description>
   <pubDate>Mon, 03 Sep 2012 16:41:47 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3604&amp;PID=14314#14314</guid>
  </item> 
 </channel>
</rss>