Invalid operation - create not allowed

Invalid operation - create not allowed

Old forum URL: forums.lhotka.net/forums/t/3725.aspx


rbellow posted on Tuesday, October 16, 2007

I am simply trying to create a new object.

Example:

MyBusinessObjects.Library.Employee.NewEmployee()

It errors with the message 'Invalid operation - create not allowed'

The trace suggests it fails in DataPortal_Create()

Any ideas on how I can get more detail as to why this is failing? I tried to comment out the ValidationRules.CheckRules() with no success.

<RunLocal()> _

Protected Overloads Sub DataPortal_Create(ByVal criteria As Object)

'ValidationRules.CheckRules()

End Sub

skagen00 replied on Tuesday, October 16, 2007

Make sure you're calling the DataPortal.Create with your criteria object - if you're calling it without a criteria object (that your overload is expecting) I suspect the DataPortal may be calling the Csla.Core.BusinessBase's DataPortal_Create directly (not your overload).

Bottom line is that the execution is running through the BusinessBase's DataPortal_Create, and that's why it's throwing the exception.

rbellow replied on Tuesday, October 16, 2007

That's exactly it. I used CodeSmith to generate the object and just assumed that the _Create would not expect a criteria object. Thanks. 

ajj3085 replied on Tuesday, October 16, 2007

Do you need to pass criteria?  If not, you want overrides, not overloads.

rbellow replied on Tuesday, October 16, 2007

Don't need it. So i will use overrides. Thanks again.

Copyright (c) Marimer LLC