Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Plugin Registration Tool crashes on ReportExecutionService.Load()

Posted on by 120

Hello CRM people,

This post is related to my last one: https://community.dynamics.com/crm/f/117/t/231194

I am still trying to execute a report I created in my CRM testenviroment from a Plugin which i trigger via custom action from a button.

My code looks like this:

NetworkCredential Credentials = new NetworkCredential("[USERNAME]", "[PASSWORD]", "[DOMAIN]");
                    Guid accountId = context.PrimaryEntityId;
                    byte[] result = null;
                    ReportExecutionService rs = new ReportExecutionService();

                    // Credential to connect with CRM
                    rs.Credentials = Credentials;

                    // Setting the URL of the Reporting Server
                    rs.Url = fullURL;

                    string reportPath = reportNameLong;
                    // Specify the report path from the reporting server
                    // Note: To get the report name, report must be published for the external use.
                    // To do this edit the report from CRM and publish it for external use.
                    // After publishing it for external use report name will be visible in the reporting server instead of the report id.

                    string format = "PDF";
                    string historyID = null;
                    string devInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
                    string encoding;
                    string mimeType;
                    string extension;
                    ReportExecution2005.Warning[] warnings = null;
                    string[] streamIDs = null;

                    ExecutionInfo execInfo = new ExecutionInfo();
                    ExecutionHeader execHeader = new ExecutionHeader();
                    rs.ExecutionHeaderValue = execHeader;
                    execInfo = rs.LoadReport(reportPath, historyID);

                    String SessionId = rs.ExecutionHeaderValue.ExecutionID;

                    result = rs.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);

The problem is that whenever I try to debug the whole thing the Plugin Registration Tool crashes without an error message on the execInfo = rs.LoadReport(reportPath, historyID); so I have no idea what is causing the problem.

I read multiple times that i should pass some credentials to the whole thing like:

                    var dsc = new ReportExecution2005.DataSourceCredentials
                    {
                        DataSourceName = "CRM",
                        UserName = userName,
                        Password = passWord
                    };

but I have no idea how, because ReportExecutionService only accepts ICredentials and not DataSourceCredentials.

I am curently pretty lost here and hope anybody could provide me with an answer how to tackle that whole thing.

Greetings from Germany!

*This post is locked for comments

  • Verified answer
    R.Seiffert Profile Picture
    R.Seiffert 120 on at
    RE: Plugin Registration Tool crashes on ReportExecutionService.Load()

    Had to set the Isolation Mode to "None" on the "Settings" registercard in the "Replay Plug-in Execution" dialog in Plugin Registration Tool...

  • R.Seiffert Profile Picture
    R.Seiffert 120 on at
    RE: Plugin Registration Tool crashes on ReportExecutionService.Load()

    The whole thing got even weirder. For a time it suddenly worked. While debugging, my Registration Tool didn't crash and i didn't got an error message on ReportExecutionService.Credentials = CredentialCache.DefaultNetworkCredentials; but now again it crashes and gives me an System.Security.Permissions.EnvironmentPermission exeption although I didn't change anything. This is really getting frustrating and you find no real answer when you search for it on google...

  • R.Seiffert Profile Picture
    R.Seiffert 120 on at
    RE: Plugin Registration Tool crashes on ReportExecutionService.Load()

    Hi thanks for the answer.

    Yes this code works when I put it in a normal ConsoleApplication and run it. So it seems that CRM is handling something different but I'm not able to find out at which point I have to change anything.

  • Gopalan Bhuvanesh Profile Picture
    Gopalan Bhuvanesh 11,397 on at
    RE: Plugin Registration Tool crashes on ReportExecutionService.Load()

    Hi

    Did you run this code outside plugin (eg. Console application)?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans