CrmException: Exception of type Microsoft.Crm.CrmException was thrown

Time for a new fix for a common problem.

When uploading a report you might get an error message. If this error message is:


NullReferenceException: Object reference not set to an instance of an object.]Microsoft.Crm.Reporting.SRSReport.convertDataSource(CrmContext context) +115Microsoft.Crm.Reporting.SRSReport..ctor(String name, String description, String xmlContent, String showin, String relatedentity, String category, CrmContext context, String filename, String origFilter) +136Microsoft.Crm.Reports.ReportCache.CreateSRSReport(String name, String description, String template, String showin, String relatedEntity, String category, String filename, Boolean isNewReport, String defaultFilter) +100Microsoft.Crm.Application.Platform.Report. InternalCreate(String xml) +629Microsoft.Crm.Application.Platform.Entity. Create() +109Microsoft.Crm.Application.Forms.AppForm.R aiseDataEvent(FormEventId eventId) +404Microsoft.Crm.Application.Forms.EndUserForm. Initialize(Entity entity) +56Microsoft.Crm.Application.Forms.EndUserForm. Execute(Entity entity) +13Microsoft.Crm.Web.Tools.ReportProperty. ReportPropertyPage.ConfigureForm() +202Microsoft.Crm.Application.Controls.AppPage. OnPreRender(EventArgs e) +30System.Web.UI.Control.PreRenderRecursiveInternal() +62System.Web.UI.Page.ProcessRequestMain() +1499

Then this post is not about your message. Please go to A Freaky Microsoft Dynamics CRM 3.0 Blog for a fix for this error.

Instead. If you get this message below, then read on for the solution:

[CrmException: Exception of type Microsoft.Crm.CrmException was thrown.] Microsoft.Crm.Application.Platform.Report. InternalCreate(String xml) +721 Microsoft.Crm.Application.Platform.Entity.Create() +109 Microsoft.Crm.Application.Forms.AppForm. RaiseDataEvent(FormEventId eventId) +408 Microsoft.Crm.Application.Forms.EndUserForm. Initialize(Entity entity) +57 Microsoft.Crm.Application.Forms.EndUserForm. Execute(Entity entity) +13 Microsoft.Crm.Web.Tools.ReportProperty. ReportPropertyPage.ConfigureForm() +202 Microsoft.Crm.Application.Controls.AppPage. OnPreRender(EventArgs e) +30 System.Web.UI.Control.PreRenderRecursiveInternal() +62 System.Web.UI.Page.ProcessRequestMain() +1499

I've been struggling with this error message myself and thanks to a posting on a newsgroup by LeeAC, I was able to upload my report. Here's the posting he made:

The issue lay with our RS permissions. In addition to failing to upload reports, we tried downloading them from CRM too. This gave us an NT permissions error. So, we opened up (localhost)/reports, navigated to the CRM datasource (typcially 'Organization_MSCRM), then properties, then security, and then added a user / group called NT AUTHORITY\NETWORK SERVICE, and gave them the permissions of CRM Publisher. After that it all worked fine.

Thanks

Lee

10 comments:

joel said...

Also, this error (or one very much like it) can occur if you're using a custom assembly in your report and there's a version mismatch between the dll loaded on the server and the one the report references. The upload process apparently is more than just a file upload -- it actually loads the report into the ReportServer process, or at least does a test run.

So let's say you have a report in production that has a bug, or needs a new feature, or whatever, and the change only needs to be made in the report -- the assembly can remain as-is. But as you're developing the upgrade let's say you throw some debug/testing function in the assembly code, recompile, and change the report reference to use the new version. Once you're all set with the report upgrade, if you try to upload it to CRM you'll get this error (or one like it) because the report is looking for a new version of the assembly but the CRM server still has the same production one it had all along.

At this point you need to do one of two things: clean up the assembly you had in development and re-deploy, or hand-edit the RDL file to change the version number to match what's on the server. I went with door number 1, but I'm pretty sure the second option might work too. YMMV.

Anonymous said...

I was able to get it working by adding <DOMAIN>\<CRM_ComputerName$> as a "Publisher for CRM" on reporting services security tab.

Ronald Lemmen said...

Thanks for sharing!

Ronbo said...

I did exactly what you said, and while I can now download reports, I still get the same exception when I try to upload. Any thoughts? Thanks

Ronbo said...

Nevermind, for some reason when i deleted the pie chart from the report it works fine. Maybe a VS problem instead. Thanks

Yeliz said...

I know it is irrelevant to your post, but I have a problem, and I would be glad if you share your idea. I have a custom entity which I want to add a referential relationship to the incident entity, as my custom entity is the primary entity. However after I publish the relationship then navigate to my custom entity's incidents area, I get the error "Object reference not set to an instance of an object". Any advice? Thanks in advance.

Ronald Lemmen said...

Yeliz,

This doesn't make much sense as there is nothing special about this. You can try to enable tracing, add a database profiler or look in the web log files and try to open the latest page manually. One of these approaches might give you more insight in why this behaviour exists. If none helps, then you would need to create an incident with Microsoft.

Hope this helps,
Ronald

Maria said...

Hi Ronald,

I get the exact same exception, but the user group has already been added, so it must be some other error. Do you have any words of wisdom?

I've also tried anonymous's advice, but unfortunately that didn't work either.

Makina said...

i m getting this error. i use php codes like bot to taking data in aspx page. and this errors given. your solution is for asp.net...

visit us said...

Hello! Thanks for your posts on the blog, I've learned a lot from them. I'm a beginner in Microsoft Dynamics solutions, so the topic of exception of type Microsoft.Crm.CrmException is quite useful for me.