views:

36

answers:

0

Hi

I have some XML Serialization and it works on my local machine but when I put it up on my hosting company and try it out it fails.

I don't know why

Server Error in '/' Application.
Object reference not set to an instance of an object.
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.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.]
   System.Xml.Serialization.XmlSerializationReader.Init(XmlReader r, XmlDeserializationEvents events, String encodingStyle, TempAssembly tempAssembly) +128
   System.Xml.Serialization.TempAssembly.InvokeReader(XmlMapping mapping, XmlReader xmlReader, XmlDeserializationEvents events, String encodingStyle) +107
   System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) +199

[InvalidOperationException: There is an error in the XML document.]
   System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) +682
   OnlineStudentPlanner3.Areas.SuperAdmin.Domain.Services.AccountImporterService.CreateSchoolAccounts(AccountImporterVM ViewModel) in line:82
   OnlineStudentPlanner3.Areas.SuperAdmin.Controllers.AccountImporterController.AccountImporter(AccountImporterVM ViewModel) in line:44
   lambda_method(Closure , ControllerBase , Object[] ) +108
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +188
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
   System.Web.Mvc.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a() +56
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +267
   System.Web.Mvc.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c() +20
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +190
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +329
   System.Web.Mvc.Controller.ExecuteCore() +115
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +42
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__4() +34
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +30
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8836913
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

I get the error on line 82

    XmlReader reader = SetSchema(ViewModel.FileUpload.InputStream);
    XmlSerializer deserializer = new XmlSerializer(typeof(Accounts)); -- line 82
    Accounts accounts = (Accounts)deserializer.Deserialize(reader);

Is there some sort of setting that I have to set or something? I am taking a upload file from the user. I am using asp.net mvc so I just use HttpPostedFileBase

I can't imagine the file being null as or empty because it is not( I have stuff written in it that I know works) and I check the file contents length to see if it is bigger than zero.

Edit

I will post a slightly altered xml document in a whilte but something I noticed is this

OnlineStudentPlanner3.Areas.SuperAdmin.Domain.Services.AccountImporterService.CreateSchoolAccounts(AccountImporterVM ViewModel) in line:82

I removed the in part for security reasons but now looking at the error again I noticed that is is pointing to

in C:\Users\UserName\Desktop\New folder

This strikes me as odd as this is on my hosting site. why is it pointing to a path where my soultion file is on my local machine.