views:

25

answers:

1

Hi,

I just published a website in vs2008 and FTP it to the live site and there is an error where some of the files are pointing to the dev server??

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

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:

[NullReferenceException: Object reference not set to an instance of an object.] Support.Models.ConsumerDataContext..ctor() in C:_work\Models\Consumer.designer.cs:41 Support.Models.Consumers..ctor() in C:_work\Models\Consumers.cs:17 Support.Controllers.HomeController..ctor() in C:_work\Controllers\HomeController.cs:22

[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.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +121

[InvalidOperationException: An error occurred when trying to create a controller of type 'Support.Controllers.HomeController'. Make sure that the controller has a parameterless public constructor.] System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +839 System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +66 System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +194 System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +86 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +392 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +263

any idea why?

btw "Consumer" is a dbml file

thanks

A: 

The file paths in the stack trace are coming from the pdb files and are based on the file paths at compilation time. They do not necessarilty mean that the running assemblies are looking there for code.

Consider these paths as aids for debugging on your development machine.

I suspect that a null reference in your model designer is actually due to a problem with differing schemas on the live and dev databases. Or from missing data that the code assumes will always be there.

Matt Lacey
Thanks for your answer Matt. DB is exactly the same as I backed it up and then restored it in the live server.
not sure what sort of code of code is assuming will be there but its not...
ok I just recreated the model and now it all works fine. Still not sure what the issue was though.
Assuming that you are using version control, diff the models (before annd after recreation) to see what changed. P.S. Don't forget to accept and upvote helpful answers ;)
Matt Lacey