<?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 : NullReferenceException when setting property with foreign key association</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : NullReferenceException when setting property with foreign key association</description>
  <pubDate>Mon, 27 Jul 2026 08:12:21 -700</pubDate>
  <lastBuildDate>Tue, 26 Oct 2010 09:54:18 -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=2241</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>NullReferenceException when setting property with foreign key association : Unfortunately, your post didn&amp;#039;t...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2241&amp;PID=8925#8925</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=975" rel="nofollow">kaftw</a><br /><strong>Subject:</strong> 2241<br /><strong>Posted:</strong> 26-Oct-2010 at 9:54am<br /><br />Unfortunately, your post didn't reach us in time and we eventually took the more drastic route of removing the entity from the model and re-adding it, then fixing up all of the navigation properties that depended on it.&nbsp; This solved the problem.&nbsp; Thank you for your time and effort in addressing this.<DIV>&nbsp;</DIV><DIV>I do have to say that I tried to use 6.0.6 to see if this would fix our issue, but I encountered another issue earlier in the application that was likely caused by the User entity being out of whack.&nbsp;&nbsp;In addition,&nbsp;I was a bit annoyed by the number of breaking changes to the API that necessitated code changes.&nbsp; It seems odd to update method signatures and remove constructors in a minor release that would cause many who use your product some unnecessary work and annoyance.&nbsp; It's certainly not encouraging us to upgrade to 6.0.6 any time soon.</DIV>]]>
   </description>
   <pubDate>Tue, 26 Oct 2010 09:54:18 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2241&amp;PID=8925#8925</guid>
  </item> 
  <item>
   <title>NullReferenceException when setting property with foreign key association : Prior to release 6.0.5, DevForce...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2241&amp;PID=8891#8891</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 2241<br /><strong>Posted:</strong> 22-Oct-2010 at 5:10pm<br /><br /><P>Prior to release 6.0.5, DevForce required that both sides of an association be present, i.e., the entity for each role needed to have the corresponding NavigationProperty defined.&nbsp; In this case, the FK_News_User association doesn't have a User.News navigation property, which results in that ugly exception.</P><DIV>The problem was fixed in the 6.0.5 release, or you can work around it in 6.0.4 by adding the property back into the model.</DIV>]]>
   </description>
   <pubDate>Fri, 22 Oct 2010 17:10:42 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2241&amp;PID=8891#8891</guid>
  </item> 
  <item>
   <title>NullReferenceException when setting property with foreign key association : OK. I assume trying to put together...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2241&amp;PID=8872#8872</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 2241<br /><strong>Posted:</strong> 21-Oct-2010 at 10:38am<br /><br />OK.&nbsp; I assume trying to put together a repro solution will be difficult to impossible, so can you send us or post&nbsp;the EDMX, along with a code snippet of the CreateUser logic?&nbsp; You can send to IdeaBladeSupportTrack, and use "&#091;#9093&#093;" in the subject line.]]>
   </description>
   <pubDate>Thu, 21 Oct 2010 10:38:59 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2241&amp;PID=8872#8872</guid>
  </item> 
  <item>
   <title>NullReferenceException when setting property with foreign key association : I tried re-generating, cleaning,...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2241&amp;PID=8870#8870</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=975" rel="nofollow">kaftw</a><br /><strong>Subject:</strong> 2241<br /><strong>Posted:</strong> 21-Oct-2010 at 8:19am<br /><br />I tried re-generating, cleaning, and rebuilding with the older version of the data model, but still had the same issue.&nbsp; It would probably be too painful to upgrade the app to use this version as we are code-freezing soon, however, if it fixes this issue, which affects a critical feature for release, then it may be necessary.&nbsp; I could try it locally and see if it fixes the issue. <DIV></DIV><DIV>&nbsp;</DIV><DIV>In response to your other questions:</DIV><DIV>- We have just one edmx.</DIV><DIV>- There aren't any many-to-many navigation properties on this entity.</DIV><DIV>- All property getters and setters are public.</DIV><DIV>- The class doesn't implement any interfaces.</DIV>]]>
   </description>
   <pubDate>Thu, 21 Oct 2010 08:19:14 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2241&amp;PID=8870#8870</guid>
  </item> 
  <item>
   <title>NullReferenceException when setting property with foreign key association : Still getting the error after...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2241&amp;PID=8861#8861</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 2241<br /><strong>Posted:</strong> 20-Oct-2010 at 4:55pm<br /><br />Still getting the error after reverting your model is bizarre.&nbsp; Is it possible that code gen didn't actually work, or that your client-side and server-side models or assemblies have somehow gotten out of sync?&nbsp; I would try re-generating, cleaning and rebuilding everything one more time just to rule out the possibility.<DIV></DIV><DIV>&nbsp;</DIV><DIV>We have fixed a number of problems with navigation properties since 6.0.4, although we hadn't seen this specific problem before, so it's hard to say whether an upgrade to the latest release (6.0.6) would help.&nbsp; It might be worth a try if upgrading isn't too painful for you right now.</DIV><DIV>&nbsp;</DIV><DIV>Other than the above, can you provide some more information on your application:</DIV><DIV>- Do you have multiple EDMX in the solution (in either one or multiple assemblies)?</DIV><DIV>- Are there any many-to-many navigation properties on this particular entity?&nbsp; </DIV><DIV>- Do any property getters or setters on this entity have other than public access?</DIV><DIV>- Does this User class implement IPrincipal/IIdentity?</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Wed, 20 Oct 2010 16:55:32 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2241&amp;PID=8861#8861</guid>
  </item> 
  <item>
   <title>NullReferenceException when setting property with foreign key association :   I recently updated my data...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2241&amp;PID=8828#8828</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=975" rel="nofollow">kaftw</a><br /><strong>Subject:</strong> 2241<br /><strong>Posted:</strong> 19-Oct-2010 at 12:30pm<br /><br />I recently updated my data model because I added a column to a table, and now for some reason, some code that set a property on one of my data model classes that was working before is now throwing an exception.<div><br></div><div>The column I added was a simple varchar column that allows nulls and has nothing to do with the values I'm trying to set. &nbsp;The properties that throw the exception are Guids that have foreign key relationships in the database table and thus also have navigation properties that are related to them. &nbsp;This only occurs when creating a new entity. &nbsp;The exception is thrown either when setting those Guid properties or when adding the new entity to the manager (I was trying to play with the order in the hopes it would work).</div><div><br></div><div>I have tried deleting the class from the designer and re-adding it, but since it's an essential class to the model, a lot of other classes had navigation properties of that type that were broken and not fixed when adding the class back in through an update of the model, so I had to revert back to the old model.</div><div><br></div><div>I even tried reverting back to the model from before I added the new column&nbsp;and forced a code gen, and I still have the same issue, which I find even more bizarre. &nbsp;The stack trace from the exception goes through a whole slew of DevForce method calls, which I've pasted below. &nbsp;We're using DevForce 6.0.4. &nbsp;I appreciate any help that can be given.</div><div><br></div><div><div>System.NullReferenceException was unhandled by user code</div><div>&nbsp;&nbsp;Message=Object reference not set to an instance of an object.</div><div>&nbsp;&nbsp;StackTrace:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.EntityReferenceBase.get_PropertyName()</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.EntityReferenceBase.set_IsLoaded(Boolean value)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.ListEntityReference`1..ctor(EntityWrapper fromWrapper, EntityRelationLink link)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.ListEntityReference`1.Clone(EntityWrapper fromWrapper)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.EntityReferenceBase.Create(EntityWrapper fromWrapper, EntityRelationLink relationLink)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.EntityWrapper.EntityReferenceManager.Get(EntityRelationLink relationLink)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.EntityWrapper.EntityReferenceManager.&lt;DiscoverRelations&gt;b__39(EntityRelationLink l)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.Core.EnumerableFns.ForEach&#091;T&#093;(IEnumerable`1 items, Action`1 action)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.EntityWrapper.EntityReferenceManager.DiscoverRelations()</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.EntityWrapper.EntityReferenceManager.get_InternalReferences()</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.EntityWrapper.FixupReferences()</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.EntityWrapper.TrackChanged(EntityChangedEventArgs e)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.EntityGroup.OnEntityChanged(EntityChangedEventArgs e)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.EntityGroup.AddNewEntity(EntityWrapper wrapper)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.EntityManager.AddEntityWrapper(EntityWrapper wrapper)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.EntityReferenceBase.AttachIfPossible(EntityWrapper newValueWrapper)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.ScalarEntityReference`1.SetEntity(T newValue, Boolean updateFkValues, Boolean updateInverseValues)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.ScalarEntityReference`1.IdeaBlade.EntityModel.IScalarEntityReference.RefreshForFkChange()</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.EntityWrapper.SetValueWithChangeNotification(DataEntityProperty property, Object newValue)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.EntityWrapper.IdeaBlade.EntityModel.IStructuralObject.SetValueWithChangeNotification(DataEntityProperty property, Object newValue)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.DataEntityProperty`2.SetValueWithVerification(TInstance instance, TValue newValue)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.DataEntityProperty`2.&lt;.ctor&gt;b__4(DataEntityPropertySetInterceptorArgs`2 args)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.Core.PropertyInterceptor`3.HandleAction(Action`1 action, TArgs args)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.Core.PropertyInterceptor`3.&lt;BuildTargetedCombinedAction&gt;b__3(TArgs args)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.Core.PropertyInterceptor`3.ExecuteActions(TArgs args)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.Core.PropertyInterceptor`3.SetValue(TInstance instance, Object context, TValue value)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.Core.PropertyInterceptor`3.SetValue(TInstance instance, TValue value)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at IdeaBlade.EntityModel.DataEntityProperty`2.SetValue(TInstance instance, TValue value)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at AST.ObjectModel.User.set_Rank(Guid value)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at AST.Common.Utilities.SL.StateManagementUtil.CreateUser(ASTEntityManager ASTEM, String akoUserName, String firstName, String lastName, String niprnetEmail, String siprnetEmail, String phone, String accessRequestNotes, Rank rank, Organization org, String dsn, Action`1 savedCallback)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at AST.Web.Home.SL.Views.NewUserRegistrationDialog.OKButton_Click(Object sender, RoutedEventArgs e)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at System.Windows.Controls.Primitives.ButtonBase.OnClick()</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at System.Windows.Controls.Button.OnClick()</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at System.Windows.Controls.Primitives.ButtonBase.OnKeyUpInternal(Key key)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at System.Windows.Controls.Primitives.ButtonBase.OnKeyUp(KeyEventArgs e)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at System.Windows.Controls.Control.OnKeyUp(Control ctrl, EventArgs e)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)</div><div>&nbsp;&nbsp;InnerException:&nbsp;</div></div><div><br></div><span style="font-size:10px"><br /><br />Edited by kaftw - 19-Oct-2010 at 12:33pm</span>]]>
   </description>
   <pubDate>Tue, 19 Oct 2010 12:30:10 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2241&amp;PID=8828#8828</guid>
  </item> 
 </channel>
</rss>