我在报表生成器上使用自定义程序集时遇到问题。我设法将我的程序集添加到报表生成器中,并允许它显示一个单词" Hello"在文本框上。当我开始添加稍微复杂的代码,比如将Ghostscript.NET代码添加到我的程序集中时,我遇到了很多障碍。
这些是我遇到问题的代码:
public PDFToImage(string path)
{
string directory = Path.GetDirectoryName(Assembly.GetAssembly(typeof(PDFToImage)).Location);
//_versionInfo = new GhostscriptVersionInfo(directory+@"\gsdll64.dll");
//_pdfURL = path;
//_initialize();
}
"目录"这里使用的变量是获取gsdll64.dll所在的当前程序集目录。因此,我可以将它传递给GhostscriptVersionInfo构造函数。
但是我在运行报告时收到了报告生成器的错误:
请求获得类型&System; Security.Security.Permissions.FileIOPermission,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'失败
报表生成器策略文件内部" RSPreviewPolicy.config" ,我添加了几个代码组并为FileIOPermission添加了权限集:
<CodeGroup class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Name="MyCodeGroup"
Description="Code group for my data processing extension">
<IMembershipCondition
class="UrlMembershipCondition"
version="1"
Url="C:\Program Files (x86)\Microsoft SQL Server\Report Builder 3.0\Spark.Conversion.Document.dll"
/>
</CodeGroup>
<CodeGroup class="UnionCodeGroup"
version="1"
PermissionSetName="IOPermission"
Name="MyCodeGroup"
Description="Code group for my data processing extension">
<IMembershipCondition
class="UrlMembershipCondition"
version="1"
Url="C:\Program Files (x86)\Microsoft SQL Server\Report Builder 3.0\Spark.Conversion.Document.dll"
/>
</CodeGroup>
<CodeGroup class="UnionCodeGroup"
version="1"
PermissionSetName="IOPermission"
Name="MyCodeGroup"
Description="Code group for my data processing extension">
<IMembershipCondition class="UrlMembershipCondition"
version="1"
Url="C:\Program Files (x86)\Microsoft SQL Server\Report Builder 3.0\Ghostscript.NET.dll"
/>
</CodeGroup>
<CodeGroup class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Name="MyCodeGroup"
Description="Code group for my data processing extension">
<IMembershipCondition class="UrlMembershipCondition"
version="1"
Url="C:\Program Files (x86)\Microsoft SQL Server\Report Builder 3.0\Ghostscript.NET.dll"
/>
</CodeGroup>
但没有任何作用。我担心如果我解决了这个问题,后续将是调用GhostscriptVersionInfo行,这是第二行代码。
有谁能告诉我如何解决这个问题?这是我将pdf转换为图像并将其显示在报告上的唯一选择。