Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling a C++ dll from reporting services report
    primarykey
    data
    text
    <p>My company currently has a product that uses crystal reports. These reports make a call out to a custom C++ dll (CRUFL) with a lot of business logic for populating certain fields on the crystal reports. My company wishes to have the product switched to use Reporting Services instead of crystal reports and I have been tasked with investigating how to re-use the CRUFL dll with reporting services.</p> <p>My following question deals specifically with the investigation path I've taken so far, but I would be more than open to any and all suggestions on how else to solve this issue.</p> <p>On another product we already use reporting services and make custom code calls from the rdl files to a C# dll. Armed with this knowledge, I thought I should be able to write a C# wrapper dll that makes P\Invoke calls to the C++ dll.</p> <p>I started by writing my own C++ code (to keep it simple) and added a very basic method to return some text (it may be clear that I know only the most basic of C++). In my CPPFile.cpp I have:</p> <pre><code>extern "C" { __declspec(dllexport) void ReturnTextFromDLL(char* &amp; rtnStr) { rtnStr = "Some return string from inside the cpp dll! \n"; } } </code></pre> <p>I then wrote a C# wrapper both containing the call to the c++ method above as well as a testing method that doesn't make a call to c++:</p> <pre><code>public static class WrapperClass { [DllImport("TestCPP.dll")] public static extern void ReturnTextFromDLL(out string output); public static string DisplayHardcodedText() { return "Some hardcoded text in WrapperClass"; } } </code></pre> <p>Now, I created a simple RDL with two textboxes. Under Report Properties, I added a reference to my C# dll (CSharpWrapper) and added the following under code:</p> <pre><code>Shared Function GetTextFromCPP() As String Dim rtnStr As String = "" CSharpWrapper.WrapperClass.ReturnTextFromDLL(rtnStr) Return rtnStr End Function Shared Function GetHardCodedTextFromWrapper() As String Return CSharpWrapper.WrapperClass.DisplayHardcodedText() End Function </code></pre> <p>For the textboxes' Expression, I have:</p> <p><code>=Code.GetTextFromCPP()</code></p> <p>and</p> <p><code>=Code.GetHardCodedTextFromWrapper()</code></p> <p>I also copied both the C++ and C# dll into my \Common7\IDE\PublicAssemblies.</p> <p>When I preview the report, the textbox that calls GetHardCodedTextFromWrapper() displays 'Some hardcoded text in WrapperClass'.</p> <p>However, the textbox that should be displaying the text from the C++ method only shows "#Error". In the output window I get:</p> <blockquote> <p>"The Value expression for the textrun 'Textbox2.Paragraphs[0].TextRuns[0]' contains an error: System.Security.Permissions.SecurityPermission"</p> </blockquote> <p>I did take this one step back and tested outside of reporting services by writing a quick C# console application and it worked without issues.</p> <p>I also tried fully deploying the report with the report manager &amp; deploying my dlls to the \ReportServer\bin but it gave the exact same result.</p> <p>So I guess what I'm asking is if it is even possible in reporting services to do this? If so, what do I need to do to get passed the SecurityPermission?</p> <p>Thanks in advance for any help with this issue.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload