Error: Method name expected?

Oct 17, 2010 at 3:27 PM

Why would the following code give me the error "Method name expected" on the container.RegisterType line?

	public interface IPropagatedCommandExecutor<TCommand>
	{
		List<ValidationError> ExecuteCommand(Action<TCommand, List<ValidationError>> action);
	}



	public class PropagatedCommandExecutor<TCommand> : IPropagatedCommandExecutor<TCommand>
	{
		public List<ValidationError> ExecuteCommand(Action<TCommand, List<ValidationError>> action)
		{
			throw new NotImplementedException();
		}
	}



	public static class ServicesBootStrapper
	{
		public static void RegisterServices(IUnityContainer container)
		{
			container.RegisterType(typeof(IPropagatedCommandExecutor<>), typeof(PropagatedCommandExecutor<>)(new HierarchicalLifetimeManager()));
		}
	}


Oct 17, 2010 at 11:06 PM

You're missing a comma after typeof(PropagatedCommandExecutor<>)

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Oct 18, 2010 at 8:51 AM
Edited Oct 18, 2010 at 8:52 AM

Ah, you mean a bracket :)

Thanks!

Oct 18, 2010 at 12:46 PM

No, not a bracket, a comma, actually.  Anyway, you probably just mistyped something.  Glad you have it working now.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Oct 18, 2010 at 5:11 PM

If you strip out the details, you've got a method call like this:

  c.R(typeof(A), typeof(B))(c);

Which is just plain incorrect syntax.

It should be:

c.R(typeof(A), typeof(B), c);

 

Oct 18, 2010 at 6:11 PM

Indeed, I am so used to x<A,B>(c) that I instinctively wrote (c) at the end :)