Create method not found on command #2456
Replies: 3 comments
-
We have a similar problem with Create methods that expect a long but get an int. So this fails
But this does not fail (added L for explicit long)
|
Beta Was this translation helpful? Give feedback.
-
Right now the FindDataPortalMethod method looks for exact parameter matches, falling back to type I suppose maybe it could do that, assigning a lower score to an assignable type compared to a direct type match. In both cases @ValentijnMakkenze, what is extremely useful is to have a unit test in the ServiceProviderMethodCallerTests class that demonstrates the failure and desired behavior. |
Beta Was this translation helpful? Give feedback.
-
@ValentijnMakkenze I'm looking at your code protected virtual void Create(object[] key) I don't think this is, or can be, supported. The client-side var command = Csla.DataPortal.Create<CommandLoadProjectData>(new[] { 3 }); C# passes that in as an array of params with one element. I don't think it can be distinguished from Specifically, your public T Create(params object[] criteria) C# will clearly take your So in both cases the server-side method signature will be resolved to: [Create]
private void Create(int x) If you really want to pass an arbitrary list of untyped values as a parameter to a data portal method, you should use a var command = DataPortal.Create<CommandLoadProjectData>(new Csla.Core.MobileList { 3 }); and [Create]
private void Create(Csla.Core.MobileList criteria) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
We get an exception after rewriting a command to get rid of the analyzer warning CSLA0011 CSLA business objects should not be created outside of a ObjectFactory instance.
We used constructors for our commands and not Create methods but after converting it the method is not called instead we get an "Invalid operation - create not allowed" exception. It looks like the objectarray is converted to an int and it can't find a create with int so it calls the base create which throws the exception.
Version and Platform
CSLA version: 5.5.1
OS: Windows
Platform: WinForms
Code that Fails
Stack Trace or Exception Detail
Csla.DataPortalException : DataPortal.Create failed (Invalid operation - create not allowed)
----> Csla.Reflection.CallMethodException : CommandLoadProjectData.DataPortal_Create method call failed
----> System.NotSupportedException : Invalid operation - create not allowed
at Csla.CommandBase
1.DataPortal_Create(Object criteria) at lambda_method(Closure , Object , Object[] ) at Csla.Reflection.ServiceProviderMethodCaller.<CallMethodTryAsync>d__11.MoveNext() at Csla.Reflection.ServiceProviderMethodCaller.<CallMethodTryAsync>d__11.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Csla.Reflection.LateBoundObject.<CallMethodTryAsyncDI>d__12
1.MoveNext()--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Csla.Server.DataPortalTarget.d__14
1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Csla.Server.DataPortalTarget.<CreateAsync>d__15.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Csla.Server.SimpleDataPortal.<Create>d__0.MoveNext() at Csla.DataPortal
1.Create(Type objectType, Object criteria)at Csla.DataPortal`1.Create(Object[] criteria)
Beta Was this translation helpful? Give feedback.
All reactions