Reply
Highlighted
Member
Posts: 8
Registered: ‎03-08-2019
Accepted Solution

controller.Execute error - Object reference not set to an instance of an object.

I get the Object reference not set to an instance of an object (shows line number of catch (Exception ex) when the controller.Execute() command is executed. I am using the AcceuptUI.js process.

 

I can use production credentials and step through Visual Studio code (c#) and the controller.Execute() command executes fine with no issues. Everything shows up on Authorize.Net's end emails are sent just like expected. But once I push code to my server for production I get the error shown below.

 

I can run test code with Sandbox credentials from the same server with no issues.

 

Is there an IIS issue or setting I am missing to execute this line of code in production? Below is the error I receive.

 

Thanks

Rick

 

 

[NullReferenceException: Object reference not set to an instance of an object.]
   MainSite.Controllers.OnlineRegistrationController.NewAuthResponse(FormCollection fc) in C:\BreakpointTech\Development\cfaerp\MainSite\Controllers\OnlineRegistrationController.cs:1690
   lambda_method(Closure , ControllerBase , Object[] ) +104
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +157
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
   System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +22
   System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
   System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +50
   System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +228
   System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
   System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +26
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36
   System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9874049
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +48
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +159

 


Accepted Solutions
Highlighted
Solution
Accepted by topic author rpenn
‎03-19-2019 05:05 AM
Member
Posts: 8
Registered: ‎03-08-2019

Re: controller.Execute error - Object reference not set to an instance of an object.

Problem solved!

 

I figured there was a library issue of some sort based on how prod worked locally and the development site on the cloud server worked too. Sure enough the updated dlls from Authorize.Net were not published during a Microsoft VS (2017) publish. My development site on the server had the new dlls but production did not. This is kind of an issue with the Microsoft Publishing process, sometimes not all updates get published. ???

 

I updated the dlls to the correct ones and now the controller.Execute() command is working correctly.

 

Thanks for your help!

 

Rick

 

View solution in original post


All Replies
Highlighted
All Star
Posts: 724
Registered: ‎11-05-2018

Re: controller.Execute error - Object reference not set to an instance of an object.

Not a C# expert but a quick glance at the error looks like you may have an absolute file path tied to the C: drive on your local machine. 

 

C:\BreakpointTech\Development\cfaerp\MainSite\Controllers\OnlineRegistrationController.cs

 

Highlighted
Member
Posts: 8
Registered: ‎03-08-2019

Re: controller.Execute error - Object reference not set to an instance of an object.

The path shows where the application is blowing up. It is blowing up in my OnlineRegistrationController. The code that is blowing up is controller.Execute();  The code works on my server using test credentials so this is bizare to me. I don't think the path is an issue.

Highlighted
All Star
Posts: 724
Registered: ‎11-05-2018

Re: controller.Execute error - Object reference not set to an instance of an object.

Yeah I got that. You were saying that you pushed the code to your server for production and you get the error. I assumed you meant a remote server and I do not use IIS.  It is not typical for linux servers to have a C drive, which is why that looked odd to me.   

 

Highlighted
Member
Posts: 8
Registered: ‎03-08-2019

Re: controller.Execute error - Object reference not set to an instance of an object.

I can see why that line sticks out as a possible issue but and have seen that before for other issues. This one just seems like the error is not matching what really is going on since the same code works in my development website that runs on the same server. The only difference is the test credentials.

 

I feel like this is a setting of some sort on the (Authorize.Net) production account. Would there be an issue if I have the Response/Receipt URL filled in? That url needs to be there for current production neeeds. And becuase the controller.Execute() command does not blow up when execute the code locally I did not think this would be an issue.

 

Any other ideas?

 

Thanks

Rick

 

Highlighted
All Star
Posts: 724
Registered: ‎11-05-2018

Re: controller.Execute error - Object reference not set to an instance of an object.

[ Edited ]
Can you post the rest of your code? The actual code would make it easier to see what’s happening. And you are using what integration method? I don’t think the receipt URL would be a dealbreaker from one environment to the next.

Without going past that first few lines of that error message (after which I am lost) the null instance is telling you that you are trying to execute the controller on an empty or non-existent object. So somehow when you define the argument you are passing in the controller it is not getting passed in production on your remote server. Or rather it is getting passed but it is null and is throwing that error.
Highlighted
Solution
Accepted by topic author rpenn
‎03-19-2019 05:05 AM
Member
Posts: 8
Registered: ‎03-08-2019

Re: controller.Execute error - Object reference not set to an instance of an object.

Problem solved!

 

I figured there was a library issue of some sort based on how prod worked locally and the development site on the cloud server worked too. Sure enough the updated dlls from Authorize.Net were not published during a Microsoft VS (2017) publish. My development site on the server had the new dlls but production did not. This is kind of an issue with the Microsoft Publishing process, sometimes not all updates get published. ???

 

I updated the dlls to the correct ones and now the controller.Execute() command is working correctly.

 

Thanks for your help!

 

Rick