Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> ORMEntityValidationException
 

Pages: 1
LLBLGen Pro Runtime Framework
ORMEntityValidationException
Page:1/1 

  Print all messages in this thread  
Poster Message
pandu
User



Location:

Joined on:
18-May-2006 07:20:06
Posted:
86 posts
# Posted on: 13-Nov-2006 07:42:11.  
I have a CreateValidator:

Code:

Protected Overrides Function CreateValidator() As IValidator
Return New ABC.DAL.ValidatorClasses.GeneralTypeValidator()
End Function


ValidatorClass:

Code:
Public Overrides Sub ValidateEntityBeforeSave(ByVal involvedEntity As IEntityCore)
Dim toValidate AsGeneralTypeEntity = CType(involvedEntity, GeneralTypeEntity)
If toValidate.GeneralType = "Abc" Then
Throw New ORMEntityValidationException("Abc is not valid General Type", toValidate)
End If
MyBase.ValidateEntityBeforeSave(involvedEntity)
End Sub


ButtonClick:

Code:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim da As New DataAccessAdapter
Dim entityGeneralType As New GeneralTypeEntity
entityGeneralType.GeneralType = "Abc"
Try
da.SaveEntity(entityGeneralType, True)
Catch ex As ORMEntityValidationException
Label1.Text = ex.Message
End Try
End Sub


When I click the Button, it throws the exception saying that it was not handled by the User code.

I handled it with Try... Catch and want to display it to the user using a Label.

Am I doing anything wrong?
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 13-Nov-2006 07:59:13.  
Please post the complete stack trace and exception exact text

  Top
pandu
User



Location:

Joined on:
18-May-2006 07:20:06
Posted:
86 posts
# Posted on: 13-Nov-2006 08:07:38.  
Stack Trace:

Code:
SD.LLBLGen.Pro.ORMSupportClasses.ORMEntityValidationException was unhandled by user code
Message="Abc is not valid General Type"
Source="ABC.DAL"
StackTrace:
at ABC.DAL.ValidatorClasses.GeneralTypeValidator.ValidateEntityBeforeSave(IEntityCore involvedEntity) in D:\ABCDAL\GeneralTypeValidator.vb:line 19
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.OnValidateEntityBeforeSave()
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.CallValidateEntityBeforeSave()
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.PersistQueue(List`1 queueToPersist, Boolean insertActions)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave, IPredicateExpression updateRestriction, Boolean recurse)



After this, the actual error message shows in the Label... Very strange.
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37803 posts
# Posted on: 13-Nov-2006 18:15:31.  
It's indeed very strange. What's odd is that the exception type isn't caught by a piece of code which definitely catches that same type.

This is in a webapplication?


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
pandu
User



Location:

Joined on:
18-May-2006 07:20:06
Posted:
86 posts
# Posted on: 14-Nov-2006 06:47:19.  
Yes Frans. It is a Web Application.

As you told me (in another thread), I have the CreateValidator Class in the same project where the created entities are. And the actual ValidatorClass is in my Web Project.

To test, in a Web Form, I have a button that saves the Entity that throws the exception and it is handled well with Try... Catch.

After the SaveEntity line, it fires to the ValidatorClass' ValidateBeforeSave Method and throws the exception after the "Throw" line immediately.

  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 14-Nov-2006 07:11:56.  
Most probably there is a version mismatch in ormsupportclasses assemblies in generated code and gui code, as the exception object's type is apparently from another assembly thus not the one in the current appdomain of the webpage

  Top
pandu
User



Location:

Joined on:
18-May-2006 07:20:06
Posted:
86 posts
# Posted on: 14-Nov-2006 08:23:31.  
Walaa:

I have three projects:

1st one is the Web Project
2 and 3 are the generated projects of LLBL (Adapter)

I have the created class in the 2nd Project where the entities are.

The Web Project has the ValidatorClass and a form that saves the entity to fire the exception.

In this, what will be the issue? I know I have the build of 17th Oct and it works fine in all other cases.

How do I verify I have the correct version? Can you explain a bit?

Thanks.

  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 14-Nov-2006 09:04:56.  
Make sure the 3 projects are referencing the same runtimeLibrarys (SD.LLBLGen.Pro.ORMSupportClasses.NETxx.dll), I mean they all are pointing to one physical path.

If the generated code was using the assemblies from the LLBLGen Pro setup folder, and the WebApp is using the a local copy, this might cause the problem -> make them all point to the local copy of the WebApp.


  Top
pandu
User



Location:

Joined on:
18-May-2006 07:20:06
Posted:
86 posts
# Posted on: 14-Nov-2006 10:07:50.  
Yes. All are referencing the same physical path of the runtime files.

Another question...

I have defined the CreateValidator in a Partial Class of the EntityClass and placed it in the same project of the created entitites.

In that, I have a line:

Return New <CustomValidator>

When I try to map out the <CustomValidator>, it doesn't recognize (no intellisense) the CustomValidator from the Web Project.

Why?

  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37803 posts
# Posted on: 14-Nov-2006 10:19:17.  
pandu wrote:
Yes. All are referencing the same physical path of the runtime files.

Could you please rebuild the complete solution and if possible not opt for per-page assemblies? We've had this reported once, however weren't able to reproduce it ourselves, however in a similar way, we ran into this issue ourselves where we changed something in the ormsupport classes to fix a bug, and tried to test it on 2 pages in the same app: we build the webapp and page 1 still showed the bug, page 2 didn't, SAME CODE. Attaching a debugger showed that page 1 used a different ormsupportclasses assembly, very strange.

Quote:

Another question...
I have defined the CreateValidator in a Partial Class of the EntityClass and placed it in the same project of the created entitites.

In that, I have a line:

Return New <CustomValidator>

When I try to map out the <CustomValidator>, it doesn't recognize (no intellisense) the CustomValidator from the Web Project.

Why?

It's a protected method, so it's not visible to code outside the class.


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.