cancel
Showing results for 
Search instead for 
Did you mean: 

Grant Full Trust to a Crystal Reports Application

Former Member
0 Kudos

I am using some Crystal Reports in an Office Addin that has been developed with Visual Studio 2008. These Crystal Reports were originally developed with Visual Studio 2003 and have worked for a long time. I am moving the Crystal Reports and the rest of the application to VS2008 and .Net Framework 3.5.

When I attempt to run any of the Crystal Reports from within the application, I get an "unrecognized query engine error". I am fairly certain that this is because Crystal Reports has not been granted full trust. I have a few other assemblies in my application and I have had to grant full trust to those assemblies to run as part of an Office Addin.

Is there a way around this problem? Will Crystal Reports run without full trust (I don't think so, but I wanted to ask anyway) If I need to grant full trust to Crystal Reports, I'm unsure of what I need to do to - what assemblies do I need to grant trust? what permissions do they need? where are they located? how do I do it?

Is there some kind of solution that already exists for this problem or am I the first one to discover it? I am deploying Crystal Reports as part of my application so whatever solution I come up with has to be deployable to a customer site.

Thanks,

Chuck

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Only suggestion I'd have is to run the utility called Process Monitor and see what it tells you about permissions (search for "Access Denied"). Process Monitor can be downloaded from here;

http://technet.microsoft.com/en-ca/sysinternals/bb896645.aspx

Ludek

Former Member
0 Kudos

Thanks, I'll give it a try and let you know. I'm surprised that others haven't run into this kind of code access security problem. Perhaps I'm seeing it because I'm running Crystal Reports from inside of an Office Add-in and Office is very restrictive about what it lets run.

In the old version of this that I developed a few years ago, I was running the same Crystal Reports from a DLL that was more loosely integrated with Office - that worked fine, but there wasn't much code access security around at that time.

Chuck

Former Member
0 Kudos

I ran the Process Monitor utility and it has tons of information in it, but its very diffcult to sift through all the information to find something significant. I've filtered out all irrelevant information and reduced it down to just the information generated by this process and there's still hundreds of events logged for just the one activity associated with producing a Crystal Report. I looked through the log of events and nothing obvious pops out as a problem. Here's a summary of some observations:

<p>u2022 All of the events show up under the u201CVisio.EXEu201D process u2013 since my application is running as a Visio Add-in, it runs in the same process space as Visio

<p>u2022 There are a number of events where the result is u201CNo Name Foundu201D u2013 Iu2019m not sure if thatu2019s an error u2013 it appears to be a normal occurrence because Iu2019ve found tons of those events throughout the log and they donu2019t appear to be associated with this Crystal Reports at all

<p>----


<p>u2022 Hereu2019s a few events in the log that looked like they might be significant:

<p> 7:29:59 PM

VISIO.EXE

2764

QueryDirectory

C:\WINDOWS\assembly\GAC_MSIL\CrystalDecisions.CrystalReports.Engine\10.5.3700.0__692fbea5521e1304

\CrystalDecisions.CrystalReports.Engine.INI

NO SUCH FILE

Filter: CrystalDecisions.CrystalReports.Engine.INI

<p> 7:29:59 PM

VISIO.EXE

2764

CloseFile

C:\WINDOWS\assembly\GAC_MSIL\CrystalDecisions.CrystalReports.Engine\10.5.3700.0__692fbea5521e1304

SUCCESS

<p>7:29:59 PM

VISIO.EXE

2764

ReadFile

C:\WINDOWS\assembly\GAC_MSIL\CrystalDecisions.CrystalReports.Engine\10.5.3700.0__692fbea5521e1304

\CrystalDecisions.CrystalReports.Engine.dll

SUCCESS

Offset: 196,608, Length: 32,768, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O

<p>7:29:59 PM

VISIO.EXE

2764

ReadFile

C:\WINDOWS\assembly\GAC_MSIL\CrystalDecisions.CrystalReports.Engine\10.5.3700.0__692fbea5521e1304

\CrystalDecisions.CrystalReports.Engine.dll

SUCCESS

Offset: 266,240, Length: 32,768, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O

<p>7:29:59 PM

VISIO.EXE

2764

QueryInformationVolume

C:\WINDOWS\assembly\GAC_MSIL\CrystalDecisions.CrystalReports.Engine\10.5.3700.0__692fbea5521e1304

\CrystalDecisions.CrystalReports.Engine.dll

SUCCESS

<p>7:29:59 PM

VISIO.EXE

2764

QueryAllInformationFille

C:\WINDOWS\assembly\GAC_MSIL\CrystalDecisions.CrystalReports.Engine\10.5.3700.0__692fbea5521e1304

\CrystalDecisions.CrystalReports.Engine.dll

BUFFER OVERFLOW CreationTime: 10/27/2009 3:40:56 PM, LastAccessTime: 11/22/2009 11:32:07 AM, LastWriteTime:

10/27/2009 3:40:56 PM, ChangeTime: 10/27/2009 3:40:56 PM, FileAttributes: A, AllocationSize: 372,736, EndOfFile:

372,736, NumberOfLinks: 1, DeletePending: False, Directory: False, IndexNumber: 0x3000000004df2, EaSize: 0, Access:

Generic Read, Position: 0, Mode: Synchronous IO Non-Alert, AlignmentRequirement: Word

<p>7:29:59 PM

VISIO.EXE

2764

QueryInformationVolume

C:\WINDOWS\assembly\GAC_MSIL\CrystalDecisions.CrystalReports.Engine\10.5.3700.0__692fbea5521e1304

\CrystalDecisions.CrystalReports.Engine.dll

SUCCESS VolumeCreationTime: 10/24/2008 1:50:18 PM, VolumeSerialNumber: DC60-56CB, SupportsObjects: True,

VolumeLabel:

<p>7:29:59 PM

VISIO.EXE

2764

QueryAllInformationFile

C:\WINDOWS\assembly\GAC_MSIL\CrystalDecisions.CrystalReports.Engine\10.5.3700.0__692fbea5521e1304

\CrystalDecisions.CrystalReports.Engine.dll

BUFFER OVERFLOW CreationTime: 10/27/2009 3:40:56 PM, LastAccessTime: 11/22/2009 11:32:07 AM, LastWriteTime: 10/27/2009 3:40:56 PM, ChangeTime: 10/27/2009 3:40:56 PM, FileAttributes: A, AllocationSize: 372,736, EndOfFile: 372,736, NumberOfLinks: 1, DeletePending: False, Directory: False, IndexNumber: 0x3000000004df2, EaSize: 0, Access: Generic Read, Position: 0, Mode: Synchronous IO Non-Alert, AlignmentRequirement: Word

<p>----


<p>What do you make of these events? Does anything here look significant? They seem to be related to the Crystal Reports problem Iu2019m having but I donu2019t know how to make a connection between the two. I donu2019t see anything that indicates a full trust problemu2026maybe my hypothesis that it is a full trust problem is incorrect. It may be something else going on here.

<p>Any additional help or advice on this would be appreciated.

<p>Thanks for your help,

<p>Chuck

Edited by: chuckc3 on Nov 23, 2009 2:03 PM

Edited by: chuckc3 on Nov 23, 2009 2:03 PM

former_member183750
Active Contributor
0 Kudos

Not much in any of the examples you posted. E.g.; a vanilla type of "stuff". Any "Access Denied" error messages?

Also, I understand you are getting "unrecognized query engine error". But is that the whole error? Query engine is essentially the guts of the database access engine. So perhaps another question is in order; can you run these reports successfully outside your add-in? E.g.; try to run the report in one of our sample apps;

https://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsfor.NETSDK+Samples

vbnet_win_dbengine is a good sample for this. Alternatively, see if a report with saved data will run (comment out any db logon code). Or create a report off of an unsecured database (say access) and try to run it in the add-in.

Ludek

Former Member
0 Kudos

Thanks, I'll work on trying to test that. I agree that would be a good thing to test. It isn't very easy to test that because the Crystal Reports run off an in-memory dataset that is built into my application, but I'm sure I can set up some kind of test and I'll let you know the result.

Thanks,

Chuck

former_member183750
Active Contributor
0 Kudos

Reports run off an in-memory dataset that is built into my application

That could be an important piece of info. The test I was wondering about in the previous post still applies, but since you are using ADO .NET datasets, see if [this|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/13270] [original link is broken] [original link is broken] [original link is broken]; blog will help you in troubleshooting the issue.

Ludek

daniel_paulsen
Active Contributor
0 Kudos

ADO.NET Datasets with VSTO add ins were known to cause this issue.

Install VS2008 SP1

then install [Crystal Reports Basic for VS2008 sp1 |https://smpdl.sap-ag.de/~sapidp/012002523100009351512008E/crbasic2008sp1.exe]from the SAP site (note this link is directly to the EXE, so save it locally before installing)

Here's the [ReadMe |https://smpdl.sap-ag.de/~sapidp/012002523100009351522008E/crbasic2008sp1_readme.pdf]for the CR Service pack. Look for ADAPT00874501.

Former Member
0 Kudos

I installed Crystal Reports SP1 and it didn't solve the problem; however, I was unable to open the link referenced above to the Readme associated with it, so I don't know if there is additional information in that readme that might be useful.

I'm working on finding a way to try the Crystal Reports outside of my application, but it is difficult to do because the application pulls data from Microsoft Visio into an in-memory dataset and the reports run directly against that dataset. Since there is no external database involved, there would be nothing for an external application to get the data from. I'll continue to work on trying to find a way to do that.

Thanks,

Former Member
0 Kudos

I made a lot of progress on this...I had to re-architect my application so that the reports and the dataset were in a separate Data Access Layer that could be called either from within the Visio Add-in or from an external Windows forms application that is a separate, standalone EXE. I've also persisted the data to a SQL Server CE database that is common to the two configurations.

When I call the Crystal Reports from my standalone EXE, it works fine...when I call the same report with the same data (and the same code to generate the report) from within the Visio Add-in, I get the unexpected query engine error. The code in both configurations that is associated with producing the reports is 98% the same...the primary difference is that the code is running inside of two different environments:

- In one case, it's running inside a standard WinForms EXE application (that works fine), and

- In the other case, it's part of a DLL that is running under the control of the Visio process as a Visio Add-in (When an application runs as a Visio Add-in, it runs in the same process space as VISIO.EXE)

I hate to give up the capability to run these reports in the Visio environment from inside the Add-in. It appears that Visio is somehow interfering with Crystal Reports' ability to produce the reports. The most likely cause to me still seems to be a code access security problem. (i.e. the Crystal Reports engine has not been granted full trust)

The reason I suspect this is that I have had a lot of other code access security problems..the VSTO loader would not load my Add-in at all until I created a security policy on the target machine that granted full trust to my Add-in assembly. I could do a similar thing for Crystal Reports, but I have no idea what assemblies I need to grant full trust to.

Any additional ideas on how to solve this problem?

Thanks,

Chuck

daniel_paulsen
Active Contributor
0 Kudos

when you get the Queryengine error, is it thrown with a System.securiy error?

to create a policy for the crystal runtime, you will need to create a full trust policy for the CrystalDecisions namespace.

Your application should run, even if your visio process is running under a different (non-domain) account such as the Local system account since I have been able to do this for web applications.

You can also try wrapping the crystal code with full trust permissions. to do this you need to create an assembly key file (using the sn.exe utility) and install your dll into the GAC. You will also need to use the AllowPartiallyTrustedCallers attribute

<Assembly: AllowPartiallyTrustedCallers()>

Your code would look similar to the following:

try

{

PermissionSet PermSet = new PermissionSet(PermissionState.Unrestricted);

PermSet.Assert();

crReport.Load(reportPath);

crReport.SetDataSource(dataSet);

CrystalReportViewer1.ReportSource = crReport;

}

catch (Exception ex)

{

Response.Write(ex.Message.ToString());

}

finally

{

//Return to permissions set for the application

CodeAccessPermission.RevertAssert();

}

Former Member
0 Kudos

Thanks for your quick reply. I modified the code to do what you suggested. The code that is most significant looks like this:


       /// <summary>
        /// Connects a Report to the Form
        /// </summary>
        /// <param name="objReport">Crystal Report to Connect</param>
        /// <param name="DS">DataSet to Use</param>
        private void ConnectReport( ReportClass objReport, DataSet DS ) 
        { 
            try 
            { 
                // ----Show Progress Form--------------------------------------------------
                frmProgress = new FormProgress( "Loading Report...Please Wait", 
                    "", true, 200); 
                frmProgress.Show();

                // ----Assert Security Permission Requirement for Crystal Reports---------
                PermissionSet PermSet = new PermissionSet(PermissionState.Unrestricted);
                PermSet.Assert();

                // ----Open Report---------------------------------------------------------
                objReport.SetDataSource( DS ); 
                crystalReportViewer1.ReportSource = objReport;

                // ----Revoke Security Permissions for Crystal Reports---------------------
                CodeAccessPermission.RevertAssert();

            } 
            catch ( Exception Exc ) 
            { 
                throw Exc; 
            } 
            finally 
            { 
                if ( !( ( frmProgress == null ) ) ) 
                { 
                    frmProgress.ResetProgress( false ); 
                    frmProgress.Close(); 
                } 
            }            
        } 

The above code is inside a Windows Form...this method "ConnectReport" is invoked in the form constructor. The only thing on this form is a Crystal Reports Viewer control. The report itself is created outside of this method and passed into this method as a parameter to connect it to the dataset and attach it to the Crystal Reports Viewer Control. The code fails at the line that says: objReport.SetDataSource( DS ). When it attempts to execute that line, I get the unknown query engine error.

Here's a summary of what I've done:

- I've moved all of the data access layer code into a separate assembly - that includes the DataSet, the code that fills the DataSet from Visio, the code that persists the data to a SQL Server CE database, all of the Crystal Reports, and this form that displays the reports

- I gave that assembly a strong signature and put it in the GAC

- I added the following line to the assemblyinfo.cs file: [assembly: AllowPartiallyTrustedCallers]

Any other ideas or suggestions I can try?

Thanks,

Chuck

Edited by: chuckc3 on Dec 10, 2009 9:11 AM

Former Member
0 Kudos

My apologies for the lack of formatting in the previous reply...I haven't been able to figure out how to get formatted HTML into a reply. Your site doesn't seem to accept formatted HTML in a reply.

<p>

Here is the complete text of the error message I receive:

<p>

CrystalDecisions.CrystalReports.Engine.DataSourceException: Unknown Query Engine Error

Error in File C:\Users\Chuck\AppData\Local\Temp\temp_33dee522-be71-42ea-96fa-a354ee819431 {C62F7717-3019-400C-B793-BCF69503BC2B}.rpt:

Unknown Query Engine Error ---> System.Runtime.InteropServices.COMException (0x800002C2): Unknown Query Engine Error

Error in File C:\Users\Chuck\AppData\Local\Temp\temp_33dee522-be71-42ea-96fa-a354ee819431 {C62F7717-3019-400C-B793-BCF69503BC2B}.rpt:

Unknown Query Engine Error

at CrystalDecisions.ReportAppServer.Controllers.DatabaseControllerClass.ReplaceConnection(Object oldConnection, Object newConnection, Object parameterFields, Object crDBOptionUseDefault)

at CrystalDecisions.CrystalReports.Engine.Table.SetDataSource(Object val, Type type)

at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type)

--- End of inner exception stack trace ---

at ProcessMapsData.Reports.FormReports.ConnectReport(ReportClass objReport, DataSet DS)

at ProcessMapsData.Reports.FormReports..ctor(ReportClass objReport, DataSet DS, Filter recordSelection)

at ProcessMapsApp.ProcessMapsApplication.ShowReport(ReportClass Report, Boolean SelectDocuments, Filter selectionFilter)

Former Member
0 Kudos

<p>Thanks for your quick reply.&#160; I modified the code to do what you suggested.&#160; The code that is most significant looks like this:</p>

<pre class="code"><span style="color: gray">/// &lt;summary&gt;

/// </span><span style="color: green">Connects a Report to the Form

</span><span style="color: gray">/// &lt;/summary&gt;

/// &lt;param name=&quot;objReport&quot;&gt;</span><span style="color: green">Crystal Report to Connect</span><span style="color: gray">&lt;/param&gt;

/// &lt;param name=&quot;DS&quot;&gt;</span><span style="color: green">DataSet to Use</span><span style="color: gray">&lt;/param&gt;

</span><span style="color: blue">private void </span>ConnectReport( <span style="color: #2b91af">ReportClass </span>objReport, <span style="color: #2b91af">DataSet </span>DS )

{

<span style="color: blue">try

</span>{

<span style="color: green">// -


Show Progress Form----


</span>frmProgress = <span style="color: blue">new </span><span style="color: #2b91af">FormProgress</span>( <span style="color: #a31515">&quot;Loading Report...Please Wait&quot;</span>,

<span style="color: #a31515">&quot;&quot;</span>, <span style="color: blue">true</span>, 200);

frmProgress.Show();

<span style="color: green">// -


Assert Security Permission Requirement for Crystal Reports----


</span><span style="color: #2b91af">PermissionSet </span>PermSet = <span style="color: blue">new </span><span style="color: #2b91af">PermissionSet</span>(<span style="color: #2b91af">PermissionState</span>.Unrestricted);

PermSet.Assert();

<span style="color: green">// -


Open Report----


</span>objReport.SetDataSource( DS );

crystalReportViewer1.ReportSource = objReport;

<span style="color: green">// -


Revoke Security Permissions for Crystal Reports----


</span><span style="color: #2b91af">CodeAccessPermission</span>.RevertAssert();

}

<span style="color: blue">catch </span>( <span style="color: #2b91af">Exception </span>Exc )

{

<span style="color: blue">throw </span>Exc;

}

<span style="color: blue">finally

</span>{

<span style="color: blue">if </span>( !( ( frmProgress == <span style="color: blue">null </span>) ) )

{

frmProgress.ResetProgress( <span style="color: blue">false </span>);

frmProgress.Close();

}

}

} </pre>

<a href="http://11011.net/software/vspaste"></a>

<p>The above code is inside a Windows Form...this method &quot;ConnectReport&quot; is invoked in the form constructor.&#160; The only thing on this form is a Crystal Reports Viewer control.&#160; The report itself is created outside of this method and passed into this method as a parameter to connect it to the dataset and attach it to the Crystal Reports Viewer Control.&#160; The code fails at the line that says: objReport.SetDataSource( DS ).&#160; When it attempts to execute that line, I get the unknown query engine error.</p>

<p>Here's a summary of what I've done:</p>

<ul>

<li>I've moved all of the data access layer code into a separate assembly - that includes the DataSet, the code that fills the DataSet from Visio, the code that persists the data to a SQL Server CE database, all of the Crystal Reports, and this form that displays the reports</li>

<li>I gave that assembly a strong signature and put it in the GAC</li>

<li>I added the following line to the assemblyinfo.cs file: [assembly: AllowPartiallyTrustedCallers]</li>

</ul>

<p>Any other ideas or suggestions I can try?</p>

<p>Thanks,</p>

<p>Chuck</p>

Former Member
0 Kudos

I have one more question...you suggested that I should develop a policy to give full trust to the CrystalDecisions namespace. I'm not sure how to give full trust to a namespace. I am using an assembl called "SetSecurity" that grants full trust to a particular assembly or to a folder containing multiple assemblies. It runs as a custom installer project when I install my application and creates an CAS security policy to grant full trust to the entire installation directory my application is installed in.

I'm not sure how I would go about granting full trust to a namespace without knowing where it is installed.

Thanks,

Chuck

daniel_paulsen
Active Contributor
0 Kudos

Hi Chuck

granting full trust to the CD namespace was done with a .NET Framework utility in Administrative Tools for the 1.0 and 1.1 Frameworks. I believe I did it using the Caspol.exe utility for the 2.0 framework, but cannot find the command line I used.

Looking at your code, I believe this should have worked so my guess is that the version of crdb_adoplus.dll might be incorrect on your machine. Can you post the version of this dll along with the build date for me?

Thanks,

Dan

Former Member
0 Kudos

I do most of my development on a 64-bit Vista system. I have two copies of the crdb_adoplus.dll installed in the following folders

Program Files\Business Objects\Common\2.8

Program Files (x86)\Business Objects\Common\2.8

Both of them appear to have the same modified date and version:

8/27/2008 - Modified Date

10.5.1.2285 - File Version

Chuck

daniel_paulsen
Active Contributor
0 Kudos

the version of your dll looks to be correct. Unfortunately I don't have time to test this on my end right now, but I did find the policy I set up for the CrystalDecisions strong name (attached). You can look for the CrystalDecisions_Strong_Name in this file to see what I've added for a web medium trust and see if it helps,

Dan

former_member183750
Active Contributor
0 Kudos

Chuck, looks like there are issues with the attachments, so the file has also been uploaded to our ftp server. You will be notified by the server, once the file is available.

Ludek

Answers (0)