Object reference error

Posts   
 
    
DrM
User
Posts: 49
Joined: 09-Feb-2004
# Posted on: 09-Jun-2005 00:40:42   

I need a fresh pair of eyes on this - it's late and this has gotta be a very obvious mistake.

I'm passing an entity to a manager class function to save and I'm getting an "Object reference not set to an instance of an object" error.

Here is the function calling line:

If taxSearchMan.saveUserSettings(userSetting) Then...

Here is the function:


Public Function saveUserSettings(ByRef pUserSettingEntity As UserSettingEntity) As Boolean
    saveUserSettings = False
    If Not (pUserSettingEntity Is Nothing) Then
      Try
        pUserSettingEntity.IsDirty = True
        saveUserSettings = adapter.SaveEntity(pUserSettingEntity, False)
      Catch ex As Exception
        Debug.WriteLine(ex.Message)
      End Try
    End If
    Return saveUserSettings
End Function

Appreciate the help.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 09-Jun-2005 09:07:41   

Please post a stacktrace so I can see where the exception occured.

Frans Bouma | Lead developer LLBLGen Pro
DrM
User
Posts: 49
Joined: 09-Feb-2004
# Posted on: 09-Jun-2005 11:20:57   

Here is the stack trace:


Line 104:     If taxSearchMan.saveUserSettings(userSetting) Then
Line 105:
Line 106:       Me.ErrMsg.Text = "Settings saved..."

Source File: c:\inetpub\wwwroot\paprocessing\paprocessing\user_settings.aspx.vb Line: 104 

Stack Trace: 
[NullReferenceException: Object reference not set to an instance of an object.]
   SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave, IPredicateExpression updateRestriction, Boolean recurse) +2287
   SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave) +44
   PAProcessing_BIZ.TaxSearchManager.saveUserSettings(UserSettingEntity& pUserSettingEntity) in T:\1private\dev\dotNET\PAProcessing BIZ\TaxSearchManager.vb:79
   paprocessing.user_settings.btnSave_Click(Object sender, ImageClickEventArgs e) in c:\inetpub\wwwroot\paprocessing\paprocessing\user_settings.aspx.vb:104
   System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +109
   System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +69
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain() +1292

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 09-Jun-2005 12:29:24   

Please be sure that the entity saved has a PK defined. If you upgrade to the latest runtime libs released a couple of days ago, do you then get another exception? (ps: these are for 1.0.2004.2 of course)

Also make sure the db specific project is up to date with the latest db changes. This means that when you refresh the catalog and re-generate code, make sure the db specific project is updated as well in your webapplication.

Frans Bouma | Lead developer LLBLGen Pro
DrM
User
Posts: 49
Joined: 09-Feb-2004
# Posted on: 09-Jun-2005 14:31:45   

Frans - I followed your advise and still had no luck. Then I made two changes at once (which I had made them one at a time) so I would know which was the culprit but hindsight etc etc.

I deleted my LLBLGen project and recreated it - it was a small project so it was quick.

I deleted my VSWebcache.

Now it works fine. I'm thinking the VSWebcache might be the real issue here - what do you think? Also I have the May 26th ver of 2004.2 - is the 8th June version much different?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 09-Jun-2005 14:47:18   

DrM wrote:

Frans - I followed your advise and still had no luck. Then I made two changes at once (which I had made them one at a time) so I would know which was the culprit but hindsight etc etc.

I deleted my LLBLGen project and recreated it - it was a small project so it was quick. I deleted my VSWebcache.

Now it works fine. I'm thinking the VSWebcache might be the real issue here - what do you think? Also I have the May 26th ver of 2004.2 - is the 8th June version much different?

It could be there was indeed an old dll in use somewhere. Anyway, you shouldn't have re-created the llblgen pro project, re-compiling and if nothing else helps, regenerating the code, should have been enough.

The 8th june version throws an exception when it detects no PK is present when saving an entity, instead of a nullreference exception. Though if it works now, I think the problem was the 2 vs.net projects being out of sync (dbspecific and dbgeneric). You've still the old .lgp file ? If so, could you please check if you load it, the PK fields are actually marked as PK in the designer?

Frans Bouma | Lead developer LLBLGen Pro