AmbiguousMatchException in FactoryDataPortal #790

Closed
iherwald opened this Issue Oct 17, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@iherwald

This exception occures after updating from CSLA v4.6.500.0 to v4.6.603.0 when using the FactoryDataPortal and having two (Factory)DataPortal methods with the same name (but different signatures) in the same class.

        public PackageEdit Create(PackageEdit.CreateNewCriteria criteria)
        {
        }
        public PackageEdit Create(PackageEdit.CreateCopyCriteria criteria)
        {
        }
Stack Trace:
at System.RuntimeType.GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)\r\n
at System.Type.GetMethod(String name, BindingFlags bindingAttr)\r\n   
at Csla.Reflection.MethodCaller.GetMethod(Type objectType, String method, Boolean hasParameters, Object[] parameters)\r\n   
at Csla.Reflection.MethodCaller.GetCachedMethod(Object obj, String method, Boolean hasParameters, Object[] parameters)\r\n   
at Csla.Reflection.MethodCaller.IsAsyncMethod(Object obj, String method, Boolean hasParameters, Object[] parameters)\r\n   
at Csla.Utilities.ThrowIfAsyncMethodOnSyncClient(Boolean isSync, Object obj, String methodName)\r\n   
at Csla.Server.FactoryDataPortal.<InvokeMethod>d__5.MoveNext()\r\n

We moved back to v4.6.500.0 and the application works without any problems.
I checked the new preview v4.7.100-Beta-17100905, but the exception still occures there.

@rockfordlhotka

This comment has been minimized.

Show comment Hide comment
@rockfordlhotka

rockfordlhotka Oct 17, 2017

Owner

This is on full .NET 4.6? Or some different flavor/version?

Owner

rockfordlhotka commented Oct 17, 2017

This is on full .NET 4.6? Or some different flavor/version?

@iherwald

This comment has been minimized.

Show comment Hide comment
@iherwald

iherwald Oct 18, 2017

@iherwald

This comment has been minimized.

Show comment Hide comment
@iherwald

iherwald Oct 19, 2017

We checked out the latest commit [4bae166] and can reproduce this behaviour in the CSLA test project (.NET 4.6).

Test class: ObjectFactoryTests

  1. add another create method to the class RootFactory (e.g. 'Create (int criteria)')
  2. deactivate method 'Create()' in class RootFactory
  3. run test 'CreateLocal'

The AmbiguousMatchException will be thrown if method 'Create()' does not exist.

namespace Csla.Test.ObjectFactory
{
  public class RootFactory
  {
        //public object Create()
        //{
        //  var obj = new Root();
        //  obj.Data = "Create";
        //  obj.Location = ApplicationContext.ExecutionLocation;
        //  obj.MarkAsNew();
        //  return obj;
        //}

        // This overload method will not be called,
        // but AmbiguousMatchException will be thrown,
        // if method 'Create()' does not exist.
        public object Create(int criteria)
        {
            return new Root();
        }

	[RunLocal]
	public object Create(SingleCriteria<Root, string> criteria)
	{
	  var obj = new Root();
	  obj.Data = "Create " + criteria.Value;
	  obj.Location = ApplicationContext.ExecutionLocation;
	  obj.MarkAsNew();
	  return obj;
	}

     }
}

iherwald commented Oct 19, 2017

We checked out the latest commit [4bae166] and can reproduce this behaviour in the CSLA test project (.NET 4.6).

Test class: ObjectFactoryTests

  1. add another create method to the class RootFactory (e.g. 'Create (int criteria)')
  2. deactivate method 'Create()' in class RootFactory
  3. run test 'CreateLocal'

The AmbiguousMatchException will be thrown if method 'Create()' does not exist.

namespace Csla.Test.ObjectFactory
{
  public class RootFactory
  {
        //public object Create()
        //{
        //  var obj = new Root();
        //  obj.Data = "Create";
        //  obj.Location = ApplicationContext.ExecutionLocation;
        //  obj.MarkAsNew();
        //  return obj;
        //}

        // This overload method will not be called,
        // but AmbiguousMatchException will be thrown,
        // if method 'Create()' does not exist.
        public object Create(int criteria)
        {
            return new Root();
        }

	[RunLocal]
	public object Create(SingleCriteria<Root, string> criteria)
	{
	  var obj = new Root();
	  obj.Data = "Create " + criteria.Value;
	  obj.Location = ApplicationContext.ExecutionLocation;
	  obj.MarkAsNew();
	  return obj;
	}

     }
}

@iherwald iherwald referenced this issue in MarimerLLC/cslaforum Nov 2, 2017

Open

CSLA .NET 4.7 (coming soon) #442

@rockfordlhotka rockfordlhotka self-assigned this Nov 6, 2017

@rockfordlhotka rockfordlhotka added the bug label Nov 6, 2017

@rockfordlhotka rockfordlhotka added this to the 4.7.100 milestone Nov 6, 2017

rockfordlhotka added a commit to rockfordlhotka/csla that referenced this issue Nov 6, 2017

@rockfordlhotka rockfordlhotka referenced this issue in MarimerLLC/cslaforum Mar 22, 2018

Open

CSLA .NET version 4.7.100 release #510

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment