I cannot figure this one out. This code has executed flawlessly for quite a while, now out of nowhere it fails. The web service it calls hasn't changed and I am kind of at a loss. The specific error is {"Configuration system failed to initialize"}
Code I'm using:
webservices.WebService ws = new webservices.WebService();
Code in the designer:
namespace NumberOneService.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.WebServiceUrl)]
[global::System.Configuration.DefaultSettingValueAttribute("http://www.webserver.services/ws_partlookup.cfc")]
public string Web_Service {
get {
return ((string)(this["Web_Service"]));
}
}
}
stack trace:
at System.Configuration.ClientConfigurationSystem.OnConfigRemoved(Object sender, InternalConfigEventArgs e)
at System.Configuration.Internal.InternalConfigRoot.RemoveConfigImpl(String configPath, BaseConfigurationRecord configRecord)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Configuration.ClientSettingsStore.ReadSettings(String sectionName, Boolean isUserScoped)
at System.Configuration.LocalFileSettingsProvider.GetPropertyValues(SettingsContext context, SettingsPropertyCollection properties)
at System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider provider)
at System.Configuration.SettingsBase.GetPropertyValueByName(String propertyName)
at System.Configuration.SettingsBase.get_Item(String propertyName)
at System.Configuration.ApplicationSettingsBase.GetPropertyValue(String propertyName)
at System.Configuration.ApplicationSettingsBase.get_Item(String propertyName)
at NumberOneService.Properties.Settings.get_Web_Service() in Number One Service\Properties\Settings.Designer.cs:line 33
at NumberOneService.webservices.WebService..ctor() in Number One Service\Web References\webservices\Reference.cs:line 46
at NumberOneService.NumberOneService.bwExecuteProcess_DoWork(Object sender, DoWorkEventArgs e) in Number One Service.cs:line 400
at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
This typically happens if you created a web service reference in a class library and then ported it over to a console app or a windows app. the web service references are stored in the settings files with a specific path.
Basically, you're missing a section declaration OR the right setting name in the config file.
please check your config files for the key which stores the url of the service. Else, paste it here and we can help further.
the exception is thrown in the web service constructor when it tries to set the Url from the config file. (host config or settings file)
Related
I have downloaded .NET Core + Vue template for ASP.NET Boilerplate (v3.7.0).
I added:
code by referencing http://aspnetboilerplate.com/Pages/Documents/Quartz-Integration.
NuGet Abp.Quartz in xxx.Application project.
MyAbpQuartzModule.cs, MyLogJob.cs in xxx.Application project:
[DependsOn(typeof(AbpAutoMapperModule), typeof(AbpQuartzModule))]
public class MyAbpQuartzModule : AbpModule
{
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
}
}
MyAbpQuartzController.cs in xxx.Web.Host project:
public class MyAbpQuartzController : AbpController
{
private readonly IQuartzScheduleJobManager _jobManager;
public MyAbpQuartzController(IQuartzScheduleJobManager jobManager)
{
_jobManager = jobManager;
}
public async Task<ActionResult> ScheduleJobWithTask()
{
await _jobManager.ScheduleAsync<MyLogJob>(
job =>
{
job.WithIdentity("MyLogJobIdentity", "MyGroup")
.WithDescription("A job to simply write logs.");
},
trigger =>
{
trigger.StartNow()
.WithSimpleSchedule(schedule =>
{
schedule.RepeatForever()
.WithIntervalInSeconds(5)
.Build();
});
});
return Content("OK, scheduled!");
}
public ContentResult TestMyAbpQuartz(string message = "")
{
return Content("OK, scheduled!");
}
}
I debugged the xxx.Web.Host project, but it didn't work.
The http://localhost:21021/MyAbpQuartz/TestMyAbpQuartz page returned:
"This page isn’t working
localhost is currently unable to handle this request.
HTTP ERROR 500"
I think that QuartzScheduleJobManager didn't register successfully.
So, what should I do?
Part of error message in Web.Host/App_Data/log.txt:
ERROR 2018-06-08 19:19:04,161 [5 ] Mvc.ExceptionHandling.AbpExceptionFilter - Can't create component 'MyNetCoreWithVueProject.Web.Host.Controllers.MyAbpQuartzController' as it has dependencies to be satisfied.
'MyNetCoreWithVueProject.Web.Host.Controllers.MyAbpQuartzController' is waiting for the following dependencies:
- Service 'Abp.Quartz.IQuartzScheduleJobManager' which was not registered.
Castle.MicroKernel.Handlers.HandlerException: Can't create component 'MyNetCoreWithVueProject.Web.Host.Controllers.MyAbpQuartzController' as it has dependencies to be satisfied.
'MyNetCoreWithVueProject.Web.Host.Controllers.MyAbpQuartzController' is waiting for the following dependencies:
- Service 'Abp.Quartz.IQuartzScheduleJobManager' which was not registered.
at Castle.MicroKernel.Handlers.DefaultHandler.AssertNotWaitingForDependency()
at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)
at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments, IReleasePolicy policy)
at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy)
at Castle.Windsor.MsDependencyInjection.ScopedWindsorServiceProvider.GetServiceInternal(Type serviceType, Boolean isOptional) in D:\Github\castle-windsor-ms-adapter\src\Castle.Windsor.MsDependencyInjection\ScopedWindsorServiceProvider.cs:line 55
at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextExceptionFilterAsync>d__23.MoveNext()
INFO 2018-06-08 19:19:04,967 [5 ] ore.Mvc.Internal.ControllerActionInvoker - Executed action MyNetCoreWithVueProject.Web.Host.Controllers.MyAbpQuartzController.TestMyAbpQuartz (MyNetCoreWithVueProject.Web.Host) in 833.6801ms
ERROR 2018-06-08 19:19:05,059 [5 ] Microsoft.AspNetCore.Server.Kestrel - Connection id "0HLED66DNH26L", Request id "0HLED66DNH26L:00000004": An unhandled exception was thrown by the application.
Castle.MicroKernel.Handlers.HandlerException: Can't create component 'MyNetCoreWithVueProject.Web.Host.Controllers.MyAbpQuartzController' as it has dependencies to be satisfied.
IQuartzScheduleJobManager should be registered by AbpQuartzModule.
I see that you already have [DependsOn(typeof(AbpQuartzModule))] on MyAbpQuartzModule.
Add [DependsOn(typeof(MyAbpQuartzModule))] to *WebHostModule:
[DependsOn(
typeof(AbpProjectNameWebCoreModule),
typeof(MyAbpQuartzModule))]
public class AbpProjectNameWebHostModule : AbpModule
If you want to register a specific class that does not fit into the conventional registration rules. ASP.NET Boilerplate provides the ITransientDependency, the IPerWebRequestDependency and the ISingletonDependency interfaces as a shortcut.
public interface IQuartzScheduleJobManager
{
//...
}
public class QuartzScheduleJobManager: IQuartzScheduleJobManager, ITransientDependency
{
//...
}
In an ASP.NET app, when trying to work with both Simple Injector and ELMAH, the following get request returns a 500 error:
GET /elmah.axd/stylesheet returns a 500 error.
The error message:
No registration for type ManifestResourceHandler could be found and an implicit registration could not be made. For the container to be able to create ManifestResourceHandler it should have only one public constructor: it has 2. See https://simpleinjector.org/one-constructor for more information.
Stack trace:
SimpleInjector.ActivationException: No registration for type ManifestResourceHandler could be found and an implicit registration could not be made. For the container to be able to create ManifestResourceHandler it should have only one public constructor: it has 2. See https://simpleinjector.org/one-constructor for more information.
at SimpleInjector.Container.ThrowNotConstructableException(Type concreteType)
at SimpleInjector.Container.ThrowMissingInstanceProducerException(Type serviceType)
at SimpleInjector.Container.ThrowInvalidRegistrationException(Type serviceType, InstanceProducer producer)
at SimpleInjector.Container.GetRegistration(Type serviceType, Boolean throwOnFailure)
at WebApp.Global.InitializeHandler(IHttpHandler handler) in .......\Global.asax.cs:line 63
at WebApp.PageInitializerModule.<>c__DisplayClass1_0.<System.Web.IHttpModule.Init>b__0(Object sender, EventArgs e) in .......\Global.asax.cs:line 48
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Following the "for more information link" mentioned above, there is a further link to some documentation on how to try to fix these types of errors. The link is:
https://simpleinjector.readthedocs.io/en/latest/extensibility.html#overriding-constructor-resolution-behavior
There, 2 fixes are proposed. I tried both fixes, and for each, got the following different errors.
First Fix
Where the GreediestConstructorBehavior is used. This fix yielded the following error message and stack trace:
First Fix Error Message:
No registration for type ManifestResourceHandler could be found and an implicit registration could not be made. The constructor of type ManifestResourceHandler contains parameter 'resourceName' of type String which can not be used for constructor injection.
First Fix Stack Trace:
SimpleInjector.ActivationException: No registration for type ManifestResourceHandler could be found and an implicit registration could not be made. The constructor of type ManifestResourceHandler contains parameter 'resourceName' of type String which can not be used for constructor injection.
at SimpleInjector.Container.ThrowNotConstructableException(Type concreteType)
at SimpleInjector.Container.ThrowMissingInstanceProducerException(Type serviceType)
at SimpleInjector.Container.ThrowInvalidRegistrationException(Type serviceType, InstanceProducer producer)
at SimpleInjector.Container.GetRegistration(Type serviceType, Boolean throwOnFailure)
at WebApp.Global.InitializeHandler(IHttpHandler handler) in .......\Global.asax.cs:line 63
at WebApp.PageInitializerModule.<>c__DisplayClass1_0.<System.Web.IHttpModule.Init>b__0(Object sender, EventArgs e) in .......\Global.asax.cs:line 48
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Second Fix
Where the MostResolvableParametersConstructorResolutionBehavior is used. This second fix yielded the following error message and stack trace:
Second Fix Error Message:
No registration for type ManifestResourceHandler could be found and an implicit registration could not be made. For the container to be able to create ManifestResourceHandler, it should contain a public constructor that only contains parameters that can be resolved.
Second Fix Stack Trace
SimpleInjector.ActivationException: No registration for type ManifestResourceHandler could be found and an implicit registration could not be made. For the container to be able to create ManifestResourceHandler, it should contain a public constructor that only contains parameters that can be resolved.
at SimpleInjector.Container.ThrowNotConstructableException(Type concreteType)
at SimpleInjector.Container.ThrowMissingInstanceProducerException(Type serviceType)
at SimpleInjector.Container.ThrowInvalidRegistrationException(Type serviceType, InstanceProducer producer)
at SimpleInjector.Container.GetRegistration(Type serviceType, Boolean throwOnFailure)
at WebApp.Global.InitializeHandler(IHttpHandler handler) in .......\Global.asax.cs:line 63
at WebApp.PageInitializerModule.<>c__DisplayClass1_0.<System.Web.IHttpModule.Init>b__0(Object sender, EventArgs e) in .......\Global.asax.cs:line 48
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Thanks to anyone who can help out with this.
Fixed by updating the PageInitializerModule class so that Simple Injector ignores the ELMAH handlers:
Before change:
public sealed class PageInitializerModule : IHttpModule
{
public static void Initialize()
{
DynamicModuleUtility.RegisterModule(typeof(PageInitializerModule));
}
void IHttpModule.Init(HttpApplication app)
{
app.PreRequestHandlerExecute += (sender, e) => {
var handler = app.Context.CurrentHandler;
if (handler != null)
{
string name = handler.GetType().Assembly.FullName;
if (!name.StartsWith("System.Web") &&
!name.StartsWith("Microsoft"))
{
Global.InitializeHandler(handler);
}
}
};
}
void IHttpModule.Dispose() { }
}
Changed to:
public sealed class PageInitializerModule : IHttpModule
{
public static void Initialize()
{
DynamicModuleUtility.RegisterModule(typeof(PageInitializerModule));
}
void IHttpModule.Init(HttpApplication app)
{
app.PreRequestHandlerExecute += (sender, e) => {
var handler = app.Context.CurrentHandler;
if (handler != null)
{
string name = handler.GetType().Assembly.FullName;
if (!name.StartsWith("System.Web") &&
!name.StartsWith("Microsoft") &&
!name.StartsWith("Elmah")) // <----- ADDED THIS -----
{
Global.InitializeHandler(handler);
}
}
};
}
void IHttpModule.Dispose() { }
}
I have WebService1. Class "MapObject" declared in WebService1's solution.
[WebMethod]
public void GetRoute(MapObject from, MapObject to)
{
// Something here
return;
}
WebService2 is using methods of WebService1. Also, WebService2 has method
[WebMethod]
public void TestMethod(MapObject obj)
{
/// something here
}
But when I try to call TestMethod I recieve
System.IndexOutOfRangeException: Индекс находился вне границ массива.
в System.Web.Services.Protocols.HttpServerType..ctor(Type type)
в System.Web.Services.Protocols.HttpServerProtocol.Initialize()
в System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
This is because MapObject can not be serialized, but I can not understand why.
I would like to know how I can solve this problem, if I need to use types of WebService1 in methods of WebService2.
I have run into a very weird issue. I have several working Fitnesse tests which insert data in a database, then test my full MVC application stack.
When I try to add 2 Component property mappings to my entity map, I get an error saying "Unable to find assembly 'FluentNHibernate ...' which seems somewhat cryptic.
All of this is being run through Fitnesse, so this could be an issue with how Fitnesse loads dependencies... I have no idea of knowing for sure though. The only thing I know is that this code runs fine until I add the 2 "Component" mappings. On top of that, those mappings run fine when this code is run through the normal web application (so I know the "Component" mapping and SessionFactory class works outside of Tests project).
Does anyone have any ideas why I would get the error message I'm getting? Please let me know if there is any other code I need to post. Any help is greatly appreciated!
DLL Versions:
NHibernate - 3.3.1.4000
FluentNHibernate - 1.3.0.733
Fitnesse - v20111026
fitSharp - 2.2.4498.25493
Here is my entity:
// namespace Reporting.Domain
public class Holdings
{
public virtual int HoldingsId { get; set; }
public virtual DateTime AsOfDate { get; set; }
public virtual string Portfolio { get; set; }
// need to add these next 2 properties!
public virtual Balances PriorPeriod { get; set; }
public virtual Balances CurrentPeriod { get; set; }
}
my mapping file:
// namespace Reporting.Infrastructure
public sealed class HoldingsMap : ClassMap<Holdings>
{
public HoldingsMap()
{
Id(x => x.HoldingsId).GeneratedBy.Identity();
Map(x => x.AsOfDate).Not.Nullable();
Map(x => x.Portfolio).Not.Nullable();
// adding these lines eventually leads to the error
Component(x=> x.PriorPeriod).ColumnPrefix("Prior");
Component(x=> x.CurrentPeriod).ColumnPrefix("Current");
}
}
my SessionFactory (the error happens when BuildSessionFactory is called):
// namespace Reporting.Infrastructure
public class SessionFactory
{
public ISessionFactory CreateSession(Action<Configuration> configurationFunction)
{
return CreateConfiguration().ExposeConfiguration(c => {}).BuildSessionFactory();
}
private FluentConfiguration CreateConfiguration()
{
var connectionString = "...";
var msSqlConfiguration = MsSqlConfiguration.MsSql2008.ConnectionString(connectionString);
var database = Fluently.Configure().Database(msSqlConfiguration);
return database.Mappings(m => m.FluentMappings.AddFromAssemblyOf<SessionFactory>().Conventions.Add(ForeignKey.EndsWith("Id")));
}
}
I get this stack trace:
__EXCEPTION__:System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
---> FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
---> System.Runtime.Serialization.SerializationException: Unable to find assembly 'FluentNHibernate, Version=1.3.0.733, Culture=neutral, PublicKeyToken=8aa435e3cb308880'.
at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)
at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallMessage methodCallMessage)
at FluentNHibernate.Utils.Extensions.DeepClone[T](T obj)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at FluentNHibernate.Visitors.ComponentReferenceResolutionVisitor.ProcessComponent(ReferenceComponentMapping mapping)
at FluentNHibernate.MappingModel.ClassBased.ReferenceComponentMapping.AcceptVisitor(IMappingModelVisitor visitor)
at FluentNHibernate.MappingModel.MappedMembers.AcceptVisitor(IMappingModelVisitor visitor)
at FluentNHibernate.MappingModel.ClassBased.ClassMappingBase.AcceptVisitor(IMappingModelVisitor visitor)
at FluentNHibernate.MappingModel.HibernateMapping.AcceptVisitor(IMappingModelVisitor visitor)
at FluentNHibernate.Utils.CollectionExtensions.Each[T](IEnumerable`1 enumerable, Action`1 each)
at FluentNHibernate.PersistenceModel.ApplyVisitors(IEnumerable`1 mappings)
at FluentNHibernate.PersistenceModel.BuildMappings()
at FluentNHibernate.PersistenceModel.Configure(Configuration cfg)
at FluentNHibernate.Cfg.MappingConfiguration.Apply(Configuration cfg)
at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration()
--- End of inner exception stack trace ---
at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration()
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
--- End of inner exception stack trace ---
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
at Reporting.Infrastructure.SessionFactory.CreateSession() in Reporting.Infrastructure\SessionFactory.cs:line 32
at Reporting.FitnesseTests.Database.Setup() in Reporting.FitnesseTests\Database.cs:line 23
--- End of inner exception stack trace ---
at fitSharp.Machine.Model.TypedValue.ThrowExceptionIfNotValid()
at fitSharp.Slim.Operators.ExecuteCall.ExecuteOperation(Tree`1 parameters)
at fitSharp.Slim.Operators.InvokeInstructionBase.Invoke(TypedValue instance, MemberName memberName, Tree`1 parameters)
FWIW, this is how I use the session factory from my Fitnesse Tests project:
// namespace Reporting.FitnesseTests
public class Database
{
public static ISession Session { get; private set; }
public static void Setup()
{
Session = new SessionFactory().CreateSession().OpenSession();
}
}
and my Fitnesse Classpath is:
!path ..\Reporting.FitnesseTests\bin\Debug\Reporting.FitnesseTests.dll
Try putting the DLLs that the test is looking for in the same folder as the fitsharp Runner.exe. One problem that I ran into is that .NET run-time dependencies that are defined in app.config are resolved from the directory in which the process is executed from which in this case is probably the directory where fitsharp resides. There is a apparently a way to use the fitsharp suite configuration file to change this behavior but I haven't been able to get it working successfully (http://fitsharp.github.com/FitSharp/SuiteConfigurationFile.html).
I'm using structure map in my asp mvc site, which i've just tried to deploy onto II6 for the first time.
The basic dependency structure is very typical:
public ControlMController(IControlMService controlMservice)
{
this._controlMservice = controlMservice;
}
...
public ControlMService(IControlMRepository repo)
{
this._repo = repo;
}
...
public SQLControlMRepository (CTRLMDataContext dataContext)
{
_db = dataContext;
}
My structureMap Registry is like this
For<IControlMService>().Use<ControlMService>();
For<IControlMRepository>().Use<SQLControlMRepository>();
//For<IControlMRepository>().Use<TestControlMRepository>();
SelectConstructor<CTRLMDataContext>(() => new CTRLMDataContext());
For<CTRLMDataContext>().LifecycleIs(new HybridLifecycle()).Use<CTRLMDataContext>();
My Controller Factory looks like this:
public class ControllerFactory : DefaultControllerFactory
{
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
{
try
{
if (controllerType == null) return base.GetControllerInstance(requestContext,controllerType);
return ObjectFactory.GetInstance(controllerType) as IController;
}
catch
{
System.Diagnostics.Debug.WriteLine(ObjectFactory.WhatDoIHave());
return null;
}
}
}
This works 100% on the development server, but it does not work on when i deployed to IIS 6 on a server.
The ControlMController which has all of the dependenies returns the following exception:
[InvalidOperationException: The IControllerFactory 'SupportTool.web.Controllers.ControllerFactory' did not return a controller for the name 'ControlM'.]
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +304
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +54
System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +7
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
All of the the other controllers which have 0 dependencies work fine on the server, so the installation of structuremap must be working a little, just not entirely :/
Self answer!
The problem was that the constructor of my datacontext was throwing because the database domain name wasn't fully qualified and while my pc resolved it, the server could not.
The inner exception containing the information wasn't showing on the error page!
:)