Skip to content
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

Occasional InvalidOperationException - "Can't find information about factory method..." #660

Closed
andyste1 opened this issue Jul 25, 2023 · 1 comment

Comments

@andyste1
Copy link

I use a typed factory, and very occasionally I'll see the following exception:

System.InvalidOperationException: Can't find information about factory method xxxxx.xxxxx.ISequenceExecutionService ResolveISequenceExecutionService. This is most likely a bug. Please report it.
at Castle.Facilities.TypedFactory.Internal.TypedFactoryInterceptor.Intercept(IInvocation invocation)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Castle.Proxies.IComponentFactoryProxy.ResolveT

(Where 'ISequenceExecutionService' is an interface in my code. I can't remember whether past occurrences have always been with this particular type).

My (large) solution has been working for over ten years and I only started to notice this problem since migrating to .Net 6 last year. I'm using Castle Windsor v5.1.2 and Core v4.4.1. Obviously this could just be a coincidence, and the exception is due to a change that I have made.

So far I have only encountered this myself when debugging in VS2022, and even then only 3 or 4 times. I'm not aware of customers experiencing this so it's not a big deal, but I'm curious to know what might be causing it, and whether upgrading to the latest NuGet packages is likely to help (although the change logs don't mention this particular issue in the bug fixes).

@jonorossi
Copy link
Member

The TypedFactoryInterceptor implements IOnBehalfAware where Windsor will provide the ComponentModel to the interceptor during resolution. The Typed Factory facility uses this to get access to the extended properties of the component that is being intercepted to access a cache of methods. It stores this cache and access it during Intercept calls:

FactoryMethod method;
if (TryGetMethod(invocation, out method) == false)
{
throw new InvalidOperationException(
string.Format("Can't find information about factory method {0}. This is most likely a bug. Please report it.",
invocation.Method));
}

I can't see any other tickets where someone has logged an InvalidOperationException for this area of code, unfortunately without more information you'll have to either get a memory dump, add some extra logging to your application to determine what state the interceptor is in, or put together an repro.

Thanks for logging it so that it comes up in search if someone else runs into the same error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants