In January 2012 updated a project that has had structuremap in place
and running since Sept 2009 (2.6.1 since March 2011).
We went from VS2008 to VS2010, MVC2 to MVC3 and from .NET 3.5 to 4.0.
Since the upgrade we have been getting some intermittent 202 errors
like the one at the end of this post. It doesn't happen all the time
and not always on the same interface so I believe the problem may be
related to structuremap cache and threading. This post looks similar
to my problem (
http://groups.google.com/group/openrasta/browse_thread/
thread/67df7a648a9cd843)
We are using topshelf and quartz scheduler so at least 15 threads
start under the main process. As messages come in via MSMQ, there are
5 topshelf services that handle these messages. The services create
audits, send emails, update the database, update a CRM and update a
Lucene index independently but use some of the same structuremap
objects. We are processing hundreds or even thousands of the same
types of messages in a day but we get this error anywhere from 3 times
a day to 3 times a week.
Has anyone experienced a problem like this? Any suggestions on how to
write a test to reproduce the error?
Here is my structuremap initialization
ObjectFactory.Initialize(
x =>
x.Scan(scan =>
{
scan.TheCallingAssembly();
scan.WithDefaultConventions();
scan.LookForRegistries();
scan.AssemblyContainingType<Instance>();
scan.AssemblyContainingType<IFileSystemManager>();
})
);
ServiceLocator.SetLocatorProvider(() => new
StructureMapServiceLocator());
Here's the error:
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
StructureMap.StructureMapException: StructureMap Exception Code: 202
No Default Instance defined for PluginFamily
Hostess.Model.IInstanceRepository, Hostess.Model, Version=1.1.1.316,
Culture=neutral, PublicKeyToken=null
at StructureMap.BuildSession.<.ctor>b__0(Type t)
at StructureMap.Util.Cache`2.get_Item(KEY key)
at StructureMap.BuildSession.CreateInstance(Type pluginType)
at StructureMap.Pipeline.Instance.createRawObject(Type pluginType,
BuildSession session)
at StructureMap.Pipeline.Instance.Build(Type pluginType,
BuildSession session)
at StructureMap.Pipeline.ConstructorInstance.Get[T](String
propertyName, BuildSession session)
at lambda_method(Closure , IArguments )
at
StructureMap.Construction.BuilderCompiler.FuncCompiler`1.<>c__DisplayClass2.<CreateBuilder>b__0(IArguments
args)
at
StructureMap.Construction.InstanceBuilder.BuildInstance(IArguments
args)
at StructureMap.Pipeline.ConstructorInstance.Build(Type pluginType,
BuildSession session, IInstanceBuilder builder)
at StructureMap.Pipeline.Instance.createRawObject(Type pluginType,
BuildSession session)
at StructureMap.Pipeline.Instance.Build(Type pluginType,
BuildSession session)
at StructureMap.Pipeline.ObjectBuilder.Resolve(Type pluginType,
Instance instance, BuildSession session)
at StructureMap.BuildSession.CreateInstance(Type pluginType,
Instance instance)
at StructureMap.BuildSession.CreateInstanceArray(Type pluginType,
Instance[] instances)
at
Subway.Common.StructureMapServiceLocator.<DoGetAllInstances>d__0.MoveNext()
at
Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.<GetAllInstances>d__0`1.MoveNext()
at Hostess.Service.Infrastructure.SearchService.HandleMessage[T](T
message)
at System.Action`1.Invoke(T obj)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo
method, Object target, Object[] arguments, SignatureStruct& sig,
MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, Boolean skipVisibilityChecks)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at Subway.Common.Subway.HandleNewMessage(Object sender, EventArgs
e)
at Subway.Common.WorkerThread.Loop()