I am following the service stack "Hello World" tutorial from http://www.servicestack.net/ServiceStack.Hello/ . But when I am trying to start the asp.net application it says "Value can't be null. Parameter Name: EndpointHost.Config".
The full exception text is:
[ArgumentNullException: Der Wert darf nicht NULL sein.
Parametername: EndpointHost.Config]
[ConfigurationErrorsException: ServiceStack: AppHost does not exist or has not been initialized. Make sure you have created an AppHost and started it with 'new AppHost().Init();' in your Global.asax Application_Start()]
ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory..cctor() in C:\src\ServiceStack\src\ServiceStack\WebHost.EndPoints\ServiceStackHttpHandlerFactory.cs:45
[TypeInitializationException: Der Typeninitialisierer für "ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory" hat eine Ausnahme verursacht.]
[TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +86
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +230
System.Activator.CreateInstance(Type type, Boolean nonPublic) +67
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1051
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +111
System.Web.Configuration.HttpHandlerAction.Create() +57
System.Web.Configuration.HandlerFactoryCache..ctor(HttpHandlerAction mapping) +19
System.Web.HttpApplication.GetFactory(HttpHandlerAction mapping) +96
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +125
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +93
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
My global class is:
public class Global : System.Web.HttpApplication
{
/// Web Service Singleton AppHost
public class InfoAppHost : AppHostBase
{
//Tell Service Stack the name of your application and where to find your web services
public InfoAppHost()
: base("Services", typeof(InfoService).Assembly) { }
public override void Configure(Funq.Container container) { }
}
protected void Application_Start(object sender, EventArgs e)
{
//Initialize your application
var appHost = new InfoAppHost();
appHost.Init();
}
}
But it seems to never get called.
Compiling the example project from the homepage works fine - but I would like to follow the example from the homepage.
Any ideas how to solve this problem ?
I've deleted my test project and tried the tutorial once again.
When creating the Global.asax file I've deleted the whole class and made another class Global in this file. It seems Application_Start never got called in this class.
The problem as you might have guessed is that appHost.Init() hasn't run. Try wrapping it in a try/catch and logging any errors that might have been thrown.
We had the same problem and solved it by setting "Activate 32-bit-applications" to true in the extended ApplicationPool Settings. (sorry, only have a german Windows so the Settings names are rough guesses)
Took me a while to figure out what I was doing wrong to cause this issue...
this happened to me because I accidentally dragged the Global.asax file into a subfolder in my project.
I found that this error is caused by the WebApiConfig. The example is using ServiceStack and does not not need ASP.NET Web API. That line needs to be commented out inthe Gloabal.asax.cs file.
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
// ** comment out ** WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
new ProteinTrackerAppHost().Init();
}
Related
Today I made a new build of my web-application (simple aspx-web-application). When I tried to load it on my server into IIS and navigated to the startpage I got following exception:
Die DLL "vsperf140.dll": Das angegebene Modul wurde nicht gefunden.
(Ausnahme von HRESULT: 0x8007007E) kann nicht geladen werden.
(means: the DLL "vsperf140.dll": the specified module could not be found.)
also the stacktrace doesn't help me a lot:
[DllNotFoundException: Die DLL "vsperf140.dll": Das angegebene Modul
wurde nicht gefunden. (Ausnahme von HRESULT: 0x8007007E) kann nicht
geladen werden.] _CAP_Enter_Function_Managed(Int32 , Int32 , Int32
) +0 ASP.global_asax..ctor() +23
[TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler
verursacht.] System.RuntimeTypeHandle.CreateInstance(RuntimeType
type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached,
RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean
skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +113
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly,
Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
+232 System.Activator.CreateInstance(Type type, Boolean nonPublic) +83 System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[]
activationAttributes, StackCrawlMark& stackMark) +1122
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr,
Binder binder, Object[] args, CultureInfo culture, Object[]
activationAttributes) +128 System.Activator.CreateInstance(Type
type, BindingFlags bindingAttr, Binder binder, Object[] args,
CultureInfo culture) +18
System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[]
args) +60
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
appContext, HttpContext context) +260
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
appContext) +296
[HttpException (0x80004005): Ein Aufrufziel hat einen Ausnahmefehler
verursacht.] System.Web.HttpRuntime.FirstRequestInit(HttpContext
context) +9930568
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
+101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +254
any idea what the problem could be? Searched in google - but seems that nobody knows something about that vsperf140.dll...
From the OP in a comment:
Seems like this came with the performance profiler. Removing the project and pulling it from TFS again solved my issue.
Removed the references of AspNetHelper in web.config.
Rebuild the whole application and then deployed to new packages on my server.
(Removing the AspNetHelper in web config directly in server didn't solve my issue)
I am developing a web application using SiteCore 8 and uCommerce. To configure uCommerce I go through Sitecore and load the uCommerce interface. This morning I tried to load the uCommerce interface in the normal way, i.e logged into Sitecore and loaded uCommerce, but got nothing more than a white screen in Sitecore. Looking at the browser console I can see 2 different 500 errors:
Failed to load resource: the server responded with a status of 500
(Internal Server Error)
http://local.myapp.co.uk/ucommerceapi/Content/undefined/RootNode
Failed to load resource: the server responded with a status of 500
(Internal Server Error)
http://local.myapp.co.uk/ucommerceapi/Localization/TranslatedStrings
Failed to load resource: the server responded with a status of 500
(Internal Server Error)
http://local.myapp.co.uk/ucommerceapi/Content/tree/RootNode Failed to
load resource: the server responded with a status of 500 (Internal
Server Error)
If I click on the url in the error I get a page that displays:
Server Error in '/' Application.
Value cannot be null. Parameter name: EndpointHost.Config
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: EndpointHost.Config
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentNullException: Value cannot be null. Parameter name:
EndpointHost.Config]
[ConfigurationErrorsException: ServiceStack: AppHost does not exist or
has not been initialized. Make sure you have created an AppHost and
started it with 'new AppHost().Init();' in your Global.asax
Application_Start()]
ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory..cctor()
+836
[TypeInitializationException: The type initializer for
'ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory' threw
an exception.]
ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory..ctor()
+0
[TargetInvocationException: Exception has been thrown by the target of
an invocation.] System.RuntimeTypeHandle.CreateInstance(RuntimeType
type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached,
RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean
skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +159
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly,
Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
+256 System.Activator.CreateInstance(Type type, Boolean nonPublic) +127 System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture,
Object[] activationAttributes, StackCrawlMark& stackMark) +14297981
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr,
Binder binder, Object[] args, CultureInfo culture, Object[]
activationAttributes) +198 System.Activator.CreateInstance(Type
type, BindingFlags bindingAttr, Binder binder, Object[] args,
CultureInfo culture) +28
System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[]
args) +83 System.Web.Configuration.HandlerFactoryCache..ctor(String
type) +57 System.Web.HttpApplication.GetFactory(String type) +94
System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+375 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
I have tried recreating the Global.asax, I have tried replacing all the sitecore folders:
sitecore
sitecore modules
sitecore_files
and the App_Config folder using files from a colleagues machine that is working fine but not luck. I can copy my colleagues solution to my PC and it works fine (except he has none of the work I have done)
Can anyone throw any light on what the problem might be?
In case anyone else stumbles on this problem. I deleted the website from IIS then recreated it and the problem has gone away. I have no idea why this has fixed the issue, as I have changed nothing in IIS for days.
I am getting the following error when trying to implement code from my peers:
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
I see there is a posting for how to "How to retrieve the LoaderException property?" here (How to retrieve the LoaderException property?)
But, I do not understand where this try catch should go since the code to implement my peers code is in the Global.asax.cs file. (see below)
Any help would be appreciated and if you DOWN VOTE me, please explain why.
namespace IMS_STS_Example_SIT
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : StsMvcHttpApplication
{
protected override void OnApplicationStarted()
{
base.OnApplicationStarted();
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}
}
Here is the full error message from the UI:
[ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.]
MyCompNameIT.Common.Utils.Installer.ConfigInstaller.Install(IWindsorContainer container, IConfigurationStore store) in C:\MyCompNameProjects\PrideLands\Common\Main\Source\MyCompNameIT.Common\MyCompNameIT.Common.Utils\Installer\ConfigInstaller.cs:80
Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] installers, DefaultComponentInstaller scope) +200
Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] installers) +144
MyCompNameIT.Common.Utils.InstallerExtension.WithMyCompNameDefaults(IWindsorContainer container) in C:\MyCompNameProjects\PrideLands\Common\Main\Source\MyCompNameIT.Common\MyCompNameIT.Common.Utils\InstallerExtension.cs:52
MyCompNameIT.Common.Web.InstallerExtension.WithMyCompNameWebMvc(IWindsorContainer container) in C:\MyCompNameProjects\PrideLands\Common\Main\Source\MyCompNameIT.Common\MyCompNameIT.Common.Web\InstallerExtension.cs:20
MyCompNameIT.Common.Web.MvcHttpApplication..cctor() in C:\MyCompNameProjects\PrideLands\Common\Main\Source\MyCompNameIT.Common\MyCompNameIT.Common.Web\IocHttpApplication.cs:30
[TypeInitializationException: The type initializer for 'MyCompNameIT.Common.Web.MvcHttpApplication' threw an exception.]
MyCompNameIT.Common.Web.MvcHttpApplication..ctor() +0
IMS_STS_Example_SIT.MvcApplication..ctor() +40
ASP.global_asax..ctor() in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\ims_sts_example_sit\2c6588da\447046b5\App_global.asax.lkasnsc6.0.cs:0
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +159
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +256
System.Activator.CreateInstance(Type type, Boolean nonPublic) +127
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +14429965
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +200
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +28
System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +83
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +312
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475
[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881108
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722297
replace StsMvcHttpApplication by MvcHttpApplication or make sure you are refering to StsMvcHttpApplication assemblies and all their dependencies
I have .net 3.5 app that I built in VS 2008. App works fine on my pc and other pc's i have tried. I have also published on several other production servers.
But my app on a particular server does not work. I have checked permissions, gave them to iisusrs, network service. Tried running process mon. but no luck. Would appreciate if somebody can help me.
[NullReferenceException: Object reference not set to an instance of an
object.] Project.Global..cctor() +500
[TypeInitializationException: The type initializer for
'Product.Global' threw an exception.] Project.Global..ctor() +0
ASP.global_asax..ctor() in
c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET
Files\Project\5b298990\c958346b\App_global.asax.aqngqd-g.0.cs:0
[TargetInvocationException: Exception has been thrown by the target of
an invocation.] System.RuntimeTypeHandle.CreateInstance(RuntimeType
type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached,
RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean
fillCache) +146 System.RuntimeType.CreateInstanceImpl(Boolean
publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +298
System.Activator.CreateInstance(Type type, Boolean nonPublic) +79
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder
binder, Object[] args, CultureInfo culture, Object[]
activationAttributes) +10371979
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
appContext, HttpContext context) +258
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
appContext) +382
[HttpException (0x80004005): Exception has been thrown by the target
of an invocation.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11411878
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +88
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +4401140
The static constructor for Product.Global is raising a NullReferenceException. This is likely due to some hard coded value that is different or unavailable on that system.
Potential candidates would be localization issues (trying to parse strings in the wrong culture) causing a value to not be initialized, a missing configuration value, or anything else that is occurring within the static initialization of that type.
I have two MVC projects that have identical configuration and they use Unity for depending injection.
The first has 10 controllers and the second one has 20 controllers and dependency injection works perfectly for all of these and has been working well for over a year now.
Today I tried to copy 1 controller from the first project to the second and when I run it I get:
[MissingMethodException: No parameterless constructor defined for this object.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +113
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +232
System.Activator.CreateInstance(Type type, Boolean nonPublic) +83
System.Activator.CreateInstance(Type type) +6
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +55
[InvalidOperationException: An error occurred when trying to create a controller of type 'Web.Admin.Controllers.ApplyController'. Make sure that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +179
System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +80
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +74
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +197
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +49
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +50
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +301
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
It looks as though for that controller only it applies the DefaultcontrollerActivator instead of the unity one.
I have been going the web.config for over an hour and it seems just fine, unity is registered and all the dependencies, and the Application_Start is identical to the one of the the first project that works with the same controller.
I can't possibly imagine why everything would work except that one controller.
I tried simplifying the controller to bare basics and this still happens.
I post some code below but I don't think it'll help because I have an identical instance that works and one that doesn't. Either way the application start looks like this:
var container = Ioc.ContainerWrapper.Container as IUnityContainer;
container
.ConfigureAutoRegistration()
.ExcludeAssemblies(t => !t.FullName.StartsWith("Alpari."))
.Include(If.ImplementsITypeName, Then.Register())
.ApplyAutoRegistration();
container.RegisterType<INHibernateContext, NHibernateContext>();
container.RegisterType<HttpContextBase>(new InjectionFactory(x => new HttpContextWrapper(HttpContext.Current)));
container.RegisterType<IAuthentication, FormsAuthenticationWrapper>();
container.RegisterType<IApplyService, ApplyService>();
/* register loads of interfaces */
AreaRegistration.RegisterAllAreas();
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new LocalizedViewEngine());
DependencyResolver.SetResolver(new UnityDependencyResolver());
The dependency resolver is applied here and this works for all controllers except the ApplyController which seems to be trying to use the default resolver.
The constructor has 10 interfaces but I tried just doing this and I get the same error:
public ApplyController(IApplyService applyService)
{
this.applyService = applyService;
}
At this point I need suggestions as to what could be wrong or how to debug this.
Try resolving the ApplyController directly from the Unity container (by calling container.Resolve<ApplyController>()). This call will fail with a descriptive exception that will explain the real problem.
For more information about why this is happing, read this.
The constructor has 10 interfaces
Not related to your problem but this sounds like a violation of the Single responsibility principle. Classes that has that many dependencies are often hard to test, read and maintain. In the future, you should try to get the number of dependencies down.
Referring your following code; I presume the issue with related to the construction phase of ApplyService. This means, container is unable to instigate ApplyService when resolved through ApplyController. You can check whether the construction chain has any hierarchical dependency, those are failing.
container.RegisterType<IApplyService, ApplyService>();