In my bootstrapper I start by doing this:
public static void Initialise()
{
var container = BuildUnityContainer();
InitializeNServiceBus(container);
DependencyResolver.SetResolver(new UnityDependencyResolver(container));
...
}
And the content of InitializeNServiceBus is like this:
private static void InitializeNServiceBus(IUnityContainer container)
{
var typesToScan = new [] {
typeof (RequestPasswordResetCommand),
typeof (CreateAccountCommand)
};
Configure.With(typesToScan)
.DefineEndpointName("somequeueonmysystem")
.UnityBuilder(container)
.XmlSerializer()
//.MsmqSubscriptionStorage()
.DisableRavenInstall()
.DisableSecondLevelRetries() //we need timeout manager for this
.DisableTimeoutManager() //we need raven db or similar for this //.RunTimeoutManager()
.MsmqTransport()
.IsTransactional(false)
.PurgeOnStartup(false)
.MsmqSubscriptionStorage()
.IsTransactional(true)
.UnicastBus()
.ImpersonateSender(false)
.SendOnly();
//.CreateBus()
// .Start(() => Configure.Instance.ForInstallationOn<NServiceBus.Installation.Environments.Windows>().Install());
}
However when I open my MVC application I get:
Static property requires null instance, non-static property requires non-null instance. Parameter name: expression
The source of the error is indicated here:
Line 82:
Line 83: Configure.With(typesToScan)
Line 84: .DefineEndpointName("InCityS.Events.UI.Nuvonet")
Line 85: .UnityBuilder(container)
The stacktrace:
[ArgumentException: Static property requires null instance, non-static property requires non-null instance.
Parameter name: expression]
System.Linq.Expressions.Expression.Property(Expression expression, PropertyInfo property) +4114402
NServiceBus.Utils.Reflection.DelegateFactory.Create(PropertyInfo property) in c:\TeamCity\buildAgent\work\nsb.master_2\src\utils\NServiceBus.Utils.Reflection\DelegateFactory.cs:91
NServiceBus.Serializers.XML.XmlMessageSerializer.InitType(Type t) in c:\TeamCity\buildAgent\work\nsb.master_2\src\impl\Serializers\NServiceBus.Serializers.XML\XmlMessageSerializer.cs:133
NServiceBus.Serializers.XML.XmlMessageSerializer.InitType(Type t) in c:\TeamCity\buildAgent\work\nsb.master_2\src\impl\Serializers\NServiceBus.Serializers.XML\XmlMessageSerializer.cs:138
NServiceBus.Serializers.XML.XmlMessageSerializer.Initialize(IEnumerable`1 types) in c:\TeamCity\buildAgent\work\nsb.master_2\src\impl\Serializers\NServiceBus.Serializers.XML\XmlMessageSerializer.cs:948
NServiceBus.Serializers.XML.Config.MessageTypesInitializer.Run() in c:\TeamCity\buildAgent\work\nsb.master_2\src\impl\Serializers\NServiceBus.Serializers.XML.Config\MessageTypesInitializer.cs:20
NServiceBus.Configure.<Initialize>b__d(IWantToRunWhenConfigurationIsComplete o) in c:\TeamCity\buildAgent\work\nsb.master_2\src\config\NServiceBus.Config\Configure.cs:305
System.Collections.Generic.List`1.ForEach(Action`1 action) +10722241
NServiceBus.Configure.Initialize() in c:\TeamCity\buildAgent\work\nsb.master_2\src\config\NServiceBus.Config\Configure.cs:304
NServiceBus.Configure.SendOnly() in c:\TeamCity\buildAgent\work\nsb.master_2\src\config\NServiceBus.Config\Configure.cs:364
InCityS.UI.Open.Bootstrapper.InitializeNServiceBus(IUnityContainer container) in d:\Data_nobackup\Projects\InCityS\trunk\UI\InCityS.UI.Open\Bootstrapper.cs:83
InCityS.UI.Open.Bootstrapper.Initialise() in d:\Data_nobackup\Projects\InCityS\trunk\UI\InCityS.UI.Open\Bootstrapper.cs:53
InCityS.UI.Open.MvcApplication.Application_Start() in d:\Data_nobackup\Projects\InCityS\trunk\UI\InCityS.UI.Open\Global.asax.cs:79
[HttpException (0x80004005): Static property requires null instance, non-static property requires non-null instance.
Parameter name: expression]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9859725
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Static property requires null instance, non-static property requires non-null instance.
Parameter name: expression]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873912
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
When I changes typesToScan to
var typesToScan = new Type[]{};
the application works again, but of course once I try to put something on the Bus it fails saying it doesn't know the type through the Scanned Types.
Anyone knows where to look or has experience with this error?
Problem detected. One of the messages I added through the types to scan had a property which was op type 'CultureInfo' which doesn't play well with the serialization.
namespace InCityS.BL.Account.Messages
{
public class CreateAccountCommand : ICommand
{
public string UserName { get; set; }
public string Password { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public CultureInfo Culture { get; set; }
}
}
was replaced by:
namespace InCityS.BL.Account.Messages
{
public class CreateAccountCommand : ICommand
{
public string UserName { get; set; }
public string Password { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Culture { get; set; }
}
}