I am using code from this page this answer.
I run my application properly on my dev environment. When I published localhost with unc network share
with caspol:
caspol.exe -m -ag 1 -url "file:////\MyMachine\MyProject*" FullTrust
I work properly as well.
I work with unc share because, my application deployed on production with unc and it is "somehow" shared hosting.
When I deploy to production I got :
System.TypeInitializationException: The type initializer for 'Microsoft.Reporting.WebForms.ReportViewer' threw an exception. ---> System.IO.FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401) at Microsoft.Reporting.WebForms.ReportViewer..cctor()
So the issue seems related to permissions, so I tried and still trying but with out success:
AppDomainSetup setup = new AppDomainSetup { ApplicationBase = AppDomain.CurrentDomain.BaseDirectory, LoaderOptimization = LoaderOptimization.NotSpecified };
setup.SetCompatibilitySwitches(new[] { "NetFx40_LegacySecurityPolicy" });
var permissionSet = new PermissionSet(System.Security.Permissions.PermissionState.None);
permissionSet.AddPermission(new FileIOPermission(FileIOPermissionAccess.AllAccess, new System.Uri(typeof(FullTrustReportviewer).Assembly.CodeBase).AbsolutePath));
permissionSet.AddPermission(new FileIOPermission(FileIOPermissionAccess.AllAccess, @"C:\myproject\packages\Microsoft.ReportViewer.Runtime.WebForms.12.0.2402.15\lib\Microsoft.ReportViewer.WebForms.dll"));
permissionSet.AddPermission(new FileIOPermission(FileIOPermissionAccess.AllAccess, @"C:\myproject\bin\Microsoft.ReportViewer.WebForms.dll"));
Microsoft.ReportViewer.WebForms.dll is set to "copy local"
But it gives at the moment : System.Security.SecurityException: 'Request failed.'
So the question is as I guessed it is related to permissions set, how can I allow ReportViewer dlls permission.
If it is not case, any helps welcomed.
User contributions licensed under CC BY-SA 3.0