New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AmbiguousMatchException in FactoryDataPortal #790

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

Comments

Projects
None yet
2 participants
@iherwald

iherwald commented Oct 17, 2017

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

Member

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

Member

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 commented 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;
	}

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