question

WilliamBuchanan-2881 avatar image
0 Votes"
WilliamBuchanan-2881 asked MartinDye-3926 commented

ReportViewer control errors - object reference erro

Hi

I am using the report viewer in an ASP.NET MVC application. It has been working up until v 150.1427.0. If I try to upgrade to that version, or the latest all I see on the page is a single line of text saying 'Object reference not set to an instance of an object.'.

Is this a known issue?

Just to note - I made no other changes to the project, other than updating the reportviewer via Nuget. Going back to the previous version fixes the problem. Also to note this doesn't happen on all reports - it is only happening on some of them.

Thanks

sql-server-reporting-services
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

StewartBeth-0700 avatar image
0 Votes"
StewartBeth-0700 answered MartinDye-3926 commented

@WilliamBuchanan-2881 I just tested the latest release (150.1449.0) and the issue has been resolved for me. Give it a try.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @StewartBeth-0700

I just tried it and agree the problem seems to have been fixed.

Thank you so much for letting me know - really appreciated!

0 Votes 0 ·

I had the same error, thank goodness for this article, it's a life saver. I rolled back to the old version. The new version must be incredible though!

0 Votes 0 ·
Joyzhao-MSFT avatar image
0 Votes"
Joyzhao-MSFT answered WilliamBuchanan-2881 commented

Hi @WilliamBuchanan-2881 ,
Variables in .NET are either reference types or value types. Value types are primitives such as integers and booleans or structures (and can be identified because they inherit from System.ValueType). Boolean variables, when declared, have a default value:

 bool mybool;
 //mybool == false

Reference types, when declared, do not have a default value:

 class ExampleClass
 {
 }
    
 ExampleClass exampleClass; //== null

If you try to access a member of a class instance using a null reference then you get a System.NullReferenceException. Which is the same as Object reference not set to an instance of an object.

This question already has answers here: What is a NullReferenceException, and how do I fix it?
You could also refer to: Debugging System.NullReferenceException-Object reference not set to an instance of an object.
Best Regards,
Joy


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Joy

Thanks for the response. I am familiar with NullReferenceExceptions.

The question is more to do with how do I find the cause when one appears in the SSRS ReportViewer control.

As I mentioned, the reports all work without problem in the older version of the control, but when I use the latest versions of the control I see this error. Also, the report works fine when run outside of the report viewer. All this suggests a problem with the report viewer control rather than my reports. On top of this there is no way I can see to debug it because it is reporting services.

Are you able to provide more details on this?

Thanks

0 Votes 0 ·

Thanks for your feedback. So far, I haven't found the reason for the issue of "Object reference not set to an instance of an object" after updating report viewer version. I will continue to open the case here to look for if anyone could provide a solution, and I will continue to follow up on this issue in the future.

0 Votes 0 ·

Thank you Joy. Is there a way for us to follow that case so that we can be made aware when it is resolved?

0 Votes 0 ·

Hi @Joyzhao-MSFT , please note my description in my other answers on exactly how to duplicate this error. If a SSRS report has a DateTime parameter that 1) accepts nulls and 2) has null as its default, the "object reference not set to an instance of an object" error will occur.

0 Votes 0 ·
Show more comments
StewartBeth-0700 avatar image
1 Vote"
StewartBeth-0700 answered

I am having this problem as well. Beginning with version 150.1440, if a report has a DateTime parameter that accepts nulls and has a default value of NULL specified, the report viewer displays "object reference not set to an instance of an object" when the report is loaded. Here is the stack trace:

Object reference not set to an instance of an object at Microsoft.ReportingServices.Common.DateTimeUtil.ParseDateToAdditionalSettingFormat(String strDateTime, CultureInfo formatProvider) at Microsoft.Reporting.WebForms.ParameterInputControlFactory.Create(ReportParameterInfo reportParam, Boolean allowQueryExecution, Boolean positioningMode) at Microsoft.Reporting.WebForms.ParameterControlCollection.Create(ReportParameterInfoCollection reportParams, Boolean allowQueryExecution, IReportViewerStyles styles, Boolean showHiddenParameters, Boolean positioningMode) at Microsoft.Reporting.WebForms.ParametersArea.CreateChildControls()

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

StewartBeth-0700 avatar image
1 Vote"
StewartBeth-0700 answered WilliamBuchanan-2881 commented

Also @WilliamBuchanan-2881 if you want to see the full error you can add an error handler to the report viewer like this:

<rsweb:ReportViewer ID="ReportViewer1" runat="server" ProcessingMode="Remote"
Width="100%" Height="100%" BackColor="White" OnReportError="ReportViewer1_ReportError">
</rsweb:ReportViewer>

Then you can add code to handle the error (and see its details). That's how I got the full info.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @StewartBeth-0700

Thanks for your response and for the tip on catching the error!

With that I was able to see the exception properly, and interestingly enough I am getting exactly the same error as you - Microsoft.ReportingServices.Common.DateTimeUtil.ParseDateToAdditionalSettingFormat.

Unfortunately there doesn't appear to be any more detail in the exception object, but at least this gives me something to go on...

Would love to know if anyone has a resolution to this....

Thanks

0 Votes 0 ·

We have had to roll back our version of the Report Viewer to deal with this. I'm not sure how to report this kind of error.

0 Votes 0 ·

Yeah we just did the same. Lost the best part of a week trying to get it working but just gave up.

Trying to report problems to Microsoft seems impossible - I have no idea where to do it either. You just seem to get sent to random forums any time you look for problem reporting.

1 Vote 1 ·