I am using a ReportViewer control from Visual Studio 2008 in local mode with objects as a data source. My classes are mapped to data tables in my database. In objects, it loads related objects as needed. Therefore, it leaves reference zero until you try to use this property, and then try to load it from the database automatically. Classes use the System.Data.SqlClient namespace.
When I interact with objects in a Windows Forms application, everything works as expected. But when I pass in an object that will be used as the report data source, and it tries to automatically load the associated object, it fails. The code creates an SqlConnection object, and when I call GetCommand () on it, the following exception is thrown:
[System.Security.SecurityException] { "Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed." } System.Security.SecurityException
I tried to find the error, but all the results that appear are intended to build CLRs running on SQL Server or ASP.Net. I tried adding the following code to my code (as suggested in the search results) before creating SqlConnection objects, but apparently did nothing:
System.Data.SqlClient.SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted).Assert();
Any ideas?
c # visual-studio-2008 winforms reporting-services sqlclient
Cuppm
source share