I've done nothing more than compile the sample SSRS delivery extension and deploy it to the server as per instructions. When I make a call to the ReportService2010 ListExtensions web service method, the extension shows up in the list of results. However, when I go to create a subscription in the Report Manager, as soon as I choose the Printer Delivery Sample from the drop-down list of available delivery extensions, I get this error:
Invalid Class Name
I'm running SSRS 2012 SP2 (11.0.5569.0) on Windows Server 2012 R2.
EDIT: I found this in the logs:
It turns out that the ReportManager (the ASP.NET UI) does log to the C:\Program Files\Microsoft SQL Server\MSRSxx.MSSQLSERVER\Reporting Services\LogFiles directory. I initially saw only subscription- (i.e. service-)related events in those files and assumed that if the ReportManager did log, those files must be elsewhere.
extensionfactory!ReportManager_0-3!53c!06/02/2015-16:27:40:: e ERROR: Exception caught instantiating Printer Delivery Sample report server extension:
System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Reflection.Assembly._GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at System.Reflection.Assembly.GetType(String name, Boolean throwOnError)
at Microsoft.ReportingServices.Diagnostics.ExtensionClassFactory.<>c__DisplayClass9.<GetExtensionLocalizedName>b__6()
at Microsoft.ReportingServices.Diagnostics.RevertImpersonationContext.<>c__DisplayClass1.<Run>b__0(Object state)
at System.Security.SecurityContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Security.SecurityContext.Run(SecurityContext securityContext, ContextCallback callback, Object state)
at Microsoft.ReportingServices.Diagnostics.RevertImpersonationContext.Run(ContextBody callback)
at Microsoft.ReportingServices.Diagnostics.ExtensionClassFactory.GetExtensionLocalizedName(Extension extConfig, Boolean removeFailuresAndContinue)
The action that failed was:
InheritanceDemand
The type of the first permission that failed was:
System.Web.AspNetHostingPermission
The first permission that failed was:
<IPermission class="System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Level="Minimal"/>
The demand was for:
<PermissionSet class="System.Security.PermissionSet" version="1">
<IPermission class="System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Level="Minimal"/>
</PermissionSet>
The granted set of the failing assembly was:
<PermissionSet class="System.Security.PermissionSet" version="1">
<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Execution"/>
<IPermission class="System.Security.Permissions.StrongNameIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" PublicKeyBlob="00240000048000009400000006020000002400005253413100040000010001009D92F3DD932D20261ADD96F81554DD22E89D6C820CE81177D791891A9415FE8499B0A22270329D737DD29FCF15784BCE44B876E2099FA06B113712581C764E7B033E3F487EA8774CB78CB79FA5951A501F4FA61496F0E07AB2A48020A99435C0F2DE60282540E72CCCB63F05ECEFB90BD542E30EE34AA8005C51F2EC0BF606C0" Name="Microsoft.Samples.ReportingServices.PrinterDeliverySample" AssemblyVersion="1.0.5627.17054"/>
<IPermission class="System.Security.Permissions.UrlIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Url="file:///C:/Program Files/Microsoft SQL Server/MSRS11.MSSQLSERVER/Reporting Services/ReportManager/bin/Microsoft.Samples.ReportingServices.PrinterDeliverySample.DLL"/>
<IPermission class="System.Security.Permissions.ZoneIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Zone="MyComputer"/>
</PermissionSet>
The assembly or AppDomain that failed was:
Microsoft.Samples.ReportingServices.PrinterDeliverySample, Version=1.0.5627.17054, Culture=neutral, PublicKeyToken=f0209f2bcebc8576
The Zone of the assembly that failed was:
MyComputer
The Url of the assembly that failed was:
file:///C:/Program Files/Microsoft SQL Server/MSRS11.MSSQLSERVER/Reporting Services/ReportManager/bin/Microsoft.Samples.ReportingServices.PrinterDeliverySample.DLL
Yes, I feel a bit foolish. Okay - now what do I do with this information? Time to brush up on Code Access Security again...
Have a look at this:
http://blogs.msdn.com/b/friis/archive/2010/06/09/system-security-securityexception-request-for-the-permission-of-type-system-web-aspnethostingpermission-failed.aspx
Try switching the Application Pool Identity to Network Service. Also, check your DLL to see if it needs to be unblocked, which is also mentioned in that article.
Can you please confirm your failed assembly available/registered at C:\windows\assembly of reportserver machine. if its not registered then try to install that in GAC "Install an Assembly into the Global Assembly Cache"
Global Assembly Cache
Related
I am working on .NET framework 4.6 Web API application. My app is working on my machine and I was able to build it in my local but when I push it to our Azure Dev OPS CI, I got this build error.
Error CS0433: The type 'ZipArchive' exists in both 'System.IO.Compression, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
: Error CS0433: The type 'ZipArchiveMode' exists in both 'System.IO.Compression, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Process 'msbuild.exe' exited with code '1'.
I have a .Net 4.5 Console Application written in C# that makes a call to SQL using Entity Framework 6.1.3 and generates a PDF. The application runs fine if you run the executable but it fails when ran through Task Scheduler. It will only run on Task Scheduler with option "Run only when user is logged in" I need it to run when not logged in.
What I did to test the executable in Task Scheduler was to mock the data gets called from Entity Framework and the application worked just fine so something tells me that Task Scheduler did not like my Entity Framework call. Yet I have other Schedule Tasks Running using Entity Framework.. Not sure what the problem is. Below is one the error seen in Windows Log.
Application: CreatePDFFile.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Data.SqlClient.SqlException
Stack:
at System.Data.Entity.Internal.RetryAction1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].PerformAction(System.__Canon)
at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(System.Action1)
at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
at System.Data.Entity.Internal.LazyInternalContext.get_ObjectContext()
at System.Data.Entity.Internal.InternalContext.ExecuteSqlQuery[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.String, System.Nullable1<Boolean>, System.Object[])
at System.Data.Entity.Internal.InternalContext.ExecuteSqlQueryAsIEnumerator[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.String, System.Nullable1, System.Object[])
at System.Data.Entity.Internal.InternalContext.ExecuteSqlQuery(System.Type, System.String, System.Nullable1<Boolean>, System.Object[])
at System.Data.Entity.Internal.InternalSqlNonSetQuery.GetEnumerator()
at System.Data.Entity.Infrastructure.DbRawSqlQuery1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].GetEnumerator()
at System.Linq.Enumerable+WhereSelectEnumerableIterator2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext()
at System.Collections.Generic.List1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]..ctor(System.Collections.Generic.IEnumerable1<System.__Canon>)
at System.Linq.Enumerable.ToList[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable1)
at Repository.MyRepository.GetData(System.String, System.String, System.String, Int32)
I am using SQL Authentication. I added a try catch error and I get this:
Login failed: The login is from an untrusted domain and cannot be used
with Windows Authentication.
After looking at my connection string, I realized that I had copied the connectionstring from my PC to the server and replaced the data source but not the credentials....So its resolved.
One of my applications runs fine on my developing machine, although if I run it on another computer the app closes as soon as it loads.
I remember I got this problem one time when I didn't deploy the app.config, but I made sure it was deployed this time.
Since the application gives absolutely no errors and all the results from Google are misguided, I have no idea what to do.
What could be causing this behavior? Even though app.config is deployed I think it may be something about it or something about one or more references, but I'm not sure.
EDIT:
Apparently there was a call stack on the event logs
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentException
Stack:
at System.Data.Common.DbProviderFactories.GetFactory(System.String)
at System.Data.Entity.Infrastructure.SqlCeConnectionFactory.CreateConnection(System.String)
at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
at System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName()
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(System.Type)
at System.Data.Entity.Internal.Linq.InternalSet`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Initialize()
at System.Data.Entity.Internal.Linq.InternalSet`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].GetEnumerator()
at System.Data.Entity.Infrastructure.DbQuery`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].System.Collections.Generic.IEnumerable<TResult>.GetEnumerator()
at System.Collections.Generic.List`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]..ctor(System.Collections.Generic.IEnumerable`1<System.__Canon>)
at System.Linq.Enumerable.ToList[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable`1<System.__Canon>)
at MyApp.Database.Repositories.GuidRepository.GetNewest()
at MyApp.Components.Common.User.SystemGuid.SetupGuid()
at MyApp.Form1.InitializeSoftWare()
at MyApp.Form1..ctor()
at MyApp.Program.Main()
I have a problem with MySql.Data in a partial trusted environment.
I've added MySql.Data to the GAC (by installing it with the MSI from the mysql.com site). As you can see here:
>gacutil /l | grep -i mysql
MySql.Data, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d,
processorArchitecture=MSIL
MySql.Data.CF, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c4
4d, processorArchitecture=MSIL
MySql.Data.Entity, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc889
69c44d, processorArchitecture=MSIL
MySql.Web, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d,
processorArchitecture=MSIL
>
I've add the following to my web.config:
<configuration>
<system.web>
<trust level="Vevida"/>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="MySql.Data, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
</assemblies>
</compilation>
</system.web>
</configuration>
But I still get the following exception:
Exception Details: System.Security.SecurityException: Request for the permission of type 'MySql.Data.MySqlClient.MySqlClientPermission, MySql.Data, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' failed.
It is thrown when I try to open a connection.
I'm not sure what I can check more.
According to the MySql documentation, I need at least the following permissions:
System.Net.SocketPermission, System.Security.Permissions.ReflectionPermission, System.Net.DnsPermission, and System.Security.Permissions.SecurityPermission
In my trust level I these:
<IPermission
class="SocketPermission"
version="1"
Unrestricted="true">
</IPermission>
<IPermission
class="ReflectionPermission"
version="1"
Flags="RestrictedMemberAccess"/>
<IPermission
class="DnsPermission"
version="1"
Unrestricted="true"/>
<IPermission
class="SecurityPermission"
version="1"
Flags="Execution,ControlPrincipal,ControlThread,SerializationFormatter"/>
As far as I can see in the documentation, this is enough. Also tried to set the SecurityPermission and ReflectionPermission to unrestricted, this didn't help.
Do you have any ideas?
MySqlClientPermission has to be added to the medium trust config as SecurityClass and IPermission. My web_mediumtrust.config addition is:
<SecurityClass Name="MySqlClientPermission"
Description="MySql.Data.MySqlClient.MySqlClientPermission,
MySql.Data, Version=6.5.4.0, Culture=neutral,
PublicKeyToken=c5687fc88969c44d"
/>
<IPermission class="MySqlClientPermission" version="1">
<add connectionString="Server=;Database=;User=;Password=;Port=;Pooling=;"
restrictions=""
KeyRestrictionBehavior="PreventUsage" />
</IPermission>
As also posted on http://www.saotn.org/mysql-connector-net-6-5-partial-trust/
Every time your code opens a MySqlConnection, the MySql client makes a demand for MySqlClientPermission on the connection string. Your application must have this permission, regardless of whether the MySql client assemblies are in the GAC or not.
The permissions listed at http://englishebook.info/1/software-to-download/656-running-connectornet-65-inside-medium-trust-level (the ones that you've mentioned in your question) are the ones need by the MySql client assemblies, not the ones needed by your ASP.NET application. To allow your application to use MySql, you will need to grant it MySqlClientPermission.
Background
I have a post-build event which I use to generate some batch files which contain the current version number of our application. The event calls a batch file, which calls a managed app which loads the assembly and uses reflection to find its version information.
Problem
When the post-build event runs locally, every is fine. When it's run under our automated build process, I see the following error in the logs. I know nothing about Code Access Security, and was hoping someone could point out the problem quickly.
call GenerateBatchFiles.bat Q:\MyApp\MyCompany.Services.Hosts.MyApp.exe
Unhandled Exception: System.Security.SecurityException: Request failed.
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException)
at System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs, PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Assembly asm, SecurityAction action)
at Version.Program.Main(String[] args)
The action that failed was:
LinkDemand
The type of the first permission that failed was:
System.Security.PermissionSet
The demand was for:
<PermissionSet class="System.Security.PermissionSet"
version="1"
Unrestricted="true"/>
The granted set of the failing assembly was:
<PermissionSet class="System.Security.PermissionSet"
version="1">
<IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Read="USERNAME"/>
<IPermission class="System.Security.Permissions.FileDialogPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Unrestricted="true"/>
<IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Read="Q:\MyApp\"
PathDiscovery="Q:\MyApp\"/>
<IPermission class="System.Security.Permissions.IsolatedStorageFilePermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Allowed="AssemblyIsolationByUser"
UserQuota="9223372036854775807"
Expiry="9223372036854775807"
Permanent="True"/>
<IPermission class="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="ReflectionEmit"/>
<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="Assertion, Execution, BindingRedirects"/>
<IPermission class="System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Unrestricted="true"/>
<IPermission class="System.Security.Permissions.UrlIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Url="file:///Q:/MyApp/Version.exe"/>
<IPermission class="System.Security.Permissions.ZoneIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Zone="Intranet"/>
<IPermission class="System.Net.DnsPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Unrestricted="true"/>
<IPermission class="System.Drawing.Printing.PrintingPermission, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
version="1"
Level="DefaultPrinting"/>
</PermissionSet>
The assembly or AppDomain that failed was:
Version, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
The Zone of the assembly that failed was:
Intranet
The Url of the assembly that failed was:
file:///Q:/MyApp/Version.exe
Which version of the framework are you using? Older versions don't trust network shares much - so you might need to use "caspol" to enable trust (or move the file locally before running it). More recently, the framework does trust mappped shares (such as Q:\), but doesn't trust UNC shares (\\someserver\whatever) without a "caspol" tweak.
The simplest option, though, is to run the exe from a local drive rather than over the network.