Quartz.NET as a Windows Service with Dependencies in the GAC - reflection

I've setup a Quartz as a windows service (using AdoJobStore if it matters) and have managed to get a ASP.NET site to communication with it via remoting to add/schedule a custom IJob that lives in my own project Company.Project.ServiceLayer.
This took me a while but all works OK on my dev machine provided the Company.Project.ServiceLayer.dll exists in both the windows service folder and the websites bin folder. However in the production environment there is a requirement to have the Company.Project.ServiceLayer.dll added to the GAC. I've tried to simulate this on my dev machine, removing the Company.Project.ServiceLayer.dll from the services folder and adding it into the GAC using gacutil. Unforunately now when the service starts up and tries to instanciate my IJob instance it is unable to load the assembly from the GAC and throws an exception "Could not load file or assembly" (full details below).
I'm guessing Quartz uses reflection along with the DB value in the [QRTZ_JOB_DETAILS].[JOB_CLASS_NAME] field to try and load the class? I could be totally wrong but since this value ("Company.Product.ServiceLayer.SchedulerJobs.QuintilesEasyJob, Company.Product.ServiceLayer") is only a partial description of the class (its missing the version and public key token) doesn't that mean that .NET won't look in the GAC when it does the reflection coz only strong named dll's can live there? Is that the reason my GAC setup is now failing? Could a Quartz windows service ever work with dll's in the GAC?
Any assistance is greatly appreciated.
2012-10-30 11:20:20,203 [4560] ERROR Topshelf.Model.ServiceCoordinator.OnServiceFault(:0) - Fault on quartz.server: Topshelf.Exceptions.ServiceControlException
Service Start Exception: quartz.server (IQuartzServer)
at Topshelf.Builders.LocalServiceBuilder`1.StartService(T service)
at Topshelf.Model.LocalServiceController`1.CallAction[TBefore,TComplete](String text, Action`1 callback, Func`1 before, Func`1 complete)
HelpLink:
Quartz.SchedulerConfigException
Failure occured during job recovery.
at Quartz.Impl.AdoJobStore.JobStoreSupport.SchedulerStarted() in c:\Work\OpenSource\quartznet\src\Quartz\Impl\AdoJobStore\JobStoreSupport.cs:line 591
at Quartz.Core.QuartzScheduler.Start() in c:\Work\OpenSource\quartznet\src\Quartz\Core\QuartzScheduler.cs:line 440
at Quartz.Server.QuartzServer.Start()
at Topshelf.Builders.LocalServiceBuilder`1.StartService(T service)
HelpLink:
Quartz.JobPersistenceException
Couldn't store trigger 'default.remotelyAddedTrigger' for 'default.remotelyAddedJob' job: Could not load file or assembly 'Company.Product.ServiceLayer' or one of its dependencies. The system cannot find the file specified.
at Quartz.Impl.AdoJobStore.JobStoreSupport.StoreTrigger(ConnectionAndTransactionHolder conn, IOperableTrigger newTrigger, IJobDetail job, Boolean replaceExisting, String state, Boolean forceState, Boolean recovering) in c:\Work\OpenSource\quartznet\src\Quartz\Impl\AdoJobStore\JobStoreSupport.cs:line 1064
at Quartz.Impl.AdoJobStore.JobStoreSupport.DoUpdateOfMisfiredTrigger(ConnectionAndTransactionHolder conn, IOperableTrigger trig, Boolean forceState, String newStateIfNotComplete, Boolean recovering) in c:\Work\OpenSource\quartznet\src\Quartz\Impl\AdoJobStore\JobStoreSupport.cs:line 876
at Quartz.Impl.AdoJobStore.JobStoreSupport.RecoverMisfiredJobs(ConnectionAndTransactionHolder conn, Boolean recovering) in c:\Work\OpenSource\quartznet\src\Quartz\Impl\AdoJobStore\JobStoreSupport.cs:line 814
at Quartz.Impl.AdoJobStore.JobStoreSupport.RecoverJobs(ConnectionAndTransactionHolder conn) in c:\Work\OpenSource\quartznet\src\Quartz\Impl\AdoJobStore\JobStoreSupport.cs:line 760
at Quartz.Impl.AdoJobStore.JobStoreSupport.<>c__DisplayClass74.<ExecuteInNonManagedTXLock>b__73(ConnectionAndTransactionHolder conn) in c:\Work\OpenSource\quartznet\src\Quartz\Impl\AdoJobStore\JobStoreSupport.cs:line 3411
at Quartz.Impl.AdoJobStore.JobStoreSupport.ExecuteInNonManagedTXLock(String lockName, Func`2 txCallback) in c:\Work\OpenSource\quartznet\src\Quartz\Impl\AdoJobStore\JobStoreSupport.cs:line 3481
at Quartz.Impl.AdoJobStore.JobStoreSupport.SchedulerStarted() in c:\Work\OpenSource\quartznet\src\Quartz\Impl\AdoJobStore\JobStoreSupport.cs:line 581
HelpLink:
System.IO.FileNotFoundException
Could not load file or assembly 'Company.Product.ServiceLayer' or one of its dependencies. The system cannot find the file specified.
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.Type.GetType(String typeName, Boolean throwOnError)
at Quartz.Simpl.SimpleTypeLoadHelper.LoadType(String name) in c:\Work\OpenSource\quartznet\src\Quartz\Simpl\SimpleTypeLoadHelper.cs:line 51
at Quartz.Impl.AdoJobStore.StdAdoDelegate.SelectJobDetail(ConnectionAndTransactionHolder conn, JobKey jobKey, ITypeLoadHelper loadHelper) in c:\Work\OpenSource\quartznet\src\Quartz\Impl\AdoJobStore\StdAdoDelegate.cs:line 788
at Quartz.Impl.AdoJobStore.JobStoreSupport.StoreTrigger(ConnectionAndTransactionHolder conn, IOperableTrigger newTrigger, IJobDetail job, Boolean replaceExisting, String state, Boolean forceState, Boolean recovering) in c:\Work\OpenSource\quartznet\src\Quartz\Impl\AdoJobStore\JobStoreSupport.cs:line 1041

There's an extension point available on StdAdoDelegate for this, method GetStorableJobTypeName can be overridden to include version and strong name information. Currently there is no configuration switch to change behavior so you need to extend SqlServerDelegate (if using SQL Server).
So new version in your derived class would be something along the lines:
protected override string GetStorableJobTypeName(Type jobType)
{
return jobType.AssemblyQualifiedName;
}
By default Quartz only uses assembly qualified name with only type and assembly name to lessen versioning problems. Be aware of them though, when version info is included in type you need to manually fix database data or create assembly version redirect if dll version number changes.

I finally sussed this one out myself. I was able to get the service to look in the GAC by adding a partial name to full/strong name mapping in the app.config like so:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<qualifyAssembly partialName="Company.Product.ServiceLayer" fullName="Company.Product.ServiceLayer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=125c3f237e3350e4"/>
</assemblyBinding>
</runtime>

Related

type (System.Web.UI.WebControls.Label) is not compatible with the type of control (ASP.controls_labelcontrol_ascx)

following problem is DotNetNuke related - but seems to me to be an asp.net related error and I do really appreciate every hint to solve this problem.
I have following problem: When editing the content of the Html module after a fresh install of DotNetNuke 7.4.2 in my dev environment (Win 8.1, , SqlServer 2008 R2 express, VS2013) the exception shown at the end raises. When installing 7.4.2 in the test environment (Win 2K8 server 64bit, SqlServer 2008 R2 express) editing the module is without an error and all works fine.
Installing was done using an empty database, modifying web.config to point to this database and calling http://dnndev.me/install/install.aspx. The web site has its own application pool and the application pool user has been granted the necessary rights to the installation folder(s). BTW: This procedure has been used successful (with modifications) beginning with DNN v4.
A google search did not show to much results. What I tried was to clear the "v4.0.30319\Temporary ASP.NET Files" folder - no success.
Does anyone has an idea what the reason for this error can be?
Thanks for your ideas,
Robert
Error: is currently unavailable. DotNetNuke.Services.Exceptions.ModuleLoadException:
The base class includes the field 'plCurrentWorkVersion', but its type (System.Web.UI.WebControls.Label)
is not compatible with the type of control (ASP.controls_labelcontrol_ascx).
---> System.Web.HttpParseException: The base class includes the field 'plCurrentWorkVersion',
but its type (System.Web.UI.WebControls.Label) is not compatible with the type of control (ASP.controls_labelcontrol_ascx).
---> System.Web.HttpParseException: The base class includes the field 'plCurrentWorkVersion', but its type (System.Web.UI.WebControls.Label)
is not compatible with the type of control (ASP.controls_labelcontrol_ascx).
at System.Web.Compilation.BaseTemplateCodeDomTreeGenerator.BuildFieldDeclaration(ControlBuilder builder)
at System.Web.Compilation.BaseTemplateCodeDomTreeGenerator.BuildSourceDataTreeFromBuilder(ControlBuilder builder, Boolean fInTemplate, Boolean topLevelControlInTemplate, PropertyEntry pse)
at System.Web.Compilation.BaseTemplateCodeDomTreeGenerator.BuildSourceDataTreeFromBuilder(ControlBuilder builder, Boolean fInTemplate, Boolean topLevelControlInTemplate, PropertyEntry pse)
at System.Web.Compilation.BaseTemplateCodeDomTreeGenerator.BuildSourceDataTreeFromBuilder(ControlBuilder builder, Boolean fInTemplate, Boolean topLevelControlInTemplate, PropertyEntry pse)
at System.Web.Compilation.TemplateControlCodeDomTreeGenerator.BuildMiscClassMembers()
at System.Web.Compilation.BaseCodeDomTreeGenerator.BuildSourceDataTree()
at System.Web.Compilation.BaseCodeDomTreeGenerator.GetCodeDomTree(CodeDomProvider codeDomProvider, StringResourceBuilder stringResourceBuilder, VirtualPath virtualPath)
at System.Web.Compilation.BaseTemplateBuildProvider.GenerateCode(AssemblyBuilder assemblyBuilder)
at System.Web.Compilation.AssemblyBuilder.AddBuildProvider(BuildProvider buildProvider)
--- End of inner exception stack trace ---
at System.Web.Compilation.AssemblyBuilder.AddBuildProvider(BuildProvider buildProvider)
at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate)
at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath)
at DotNetNuke.UI.ControlUtilities.LoadControl[T](TemplateControl containerControl, String ControlSrc)
at DotNetNuke.UI.Modules.ModuleControlFactory.LoadModuleControl(TemplateControl containerControl, ModuleInfo moduleConfiguration)
at DotNetNuke.UI.Modules.ModuleHost.LoadModuleControl()
--- End of inner exception stack trace ---
The related piece of markup code is
<asp:Label id="plCurrentWorkVersion" runat="server" text="Version" ResourceKey="plCurrentWorkVersion" />
If you've already deleted the site, then it is probably too late to check, but I would have checked if under the site there was an Application/VirtualDirectory on DesktopModules, or any of the sub folders in there. This is a common problem with my templates in Visual Studio, for some reason, randomly, VS will turn those folders into an individual application which causes all sorts of chaos until you remove the application in IIS.
The site dnndev.me (and its application) had been used for other installations before.
Deleting and recreating the site (implying the application) solved the error (please note, that creating a new application pool was not enough).
If there is an explanation for this I would really appreciate this.
Edit: Comparing the current applicationHost.config with an older one showed the reason for the error: there was an additional entry which pointed into a fully qualified name of a path in an other old version. This resulted in a compilation using two versions (and this is what Panagiotis already wrote).

"module could not be found" error with C++/CLI component in ASP.NET

I have to include a (managed) C++/CLI component in one of my ASP.NET projects, that references for itself some other (unmanaged) C++ DLLs. Should be no problem - .NET 3.5 is happy when compiling the project, everything seems fine. The C++/CLI component and the other C++ DLLs are compiled by another department as Release version with "Any CPU" in Visual Studio 2005. The VC++ 2005 Redistributable package is installed. And the same code works without problem when I run it inside of a normal .NET console application.
Now while this code works in a console app, it's not being hosted correctly by ASP.NET - it leads an error on the initial page load (even before stepping into the Global.asax).
For testing and debugging, I have used two machine configurations:
Local Dev PC: Windows XP, 32 Bit, VC++ 2005 Redist Package, Visual Studio 2010, ASP.NET 3.5, Compiling "Any CPU", Hosting in Web Development Server (Cassini)
Test Server (target machine): Windows 7, 64 Bit, VC++ 2005 Redist Package, Hosting in IIS 7, AppPool has "Enable 32-Bit Applications" set
On both machines the same following error occurs when I start the ASP.NET application:
Exception Details: System.IO.FileNotFoundException: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[FileNotFoundException: The specified module could not be found. (Exception from HRESULT: 0x8007007E)]
System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark&amp;amp;amp; stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark&amp;amp;amp; stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark&amp;amp;amp; stackMark, Boolean forIntrospection) +127
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +142
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46
[ConfigurationErrorsException: The specified module could not be found. (Exception from HRESULT: 0x8007007E)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +613
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +105
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +163
System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +53
System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors) +175
System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +86
System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +261
System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +101
System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +126
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +62
System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +33
System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +40
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +160
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +93
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Now this is weird... It doesn't say anything about what assembly is missing, even Fuslogvw.exe or sxstrace.exe aren't logging anything.
Moreover of coures it seems that the error depends on the C++/CLI assembly or on the unmanaged C++ DLLs. If I remove the C++/CLI assembly reference from my ASP.NET project and the code, it works fine. Now because the C++/CLI assembly depends on native C++ DLLs that are not referenced in the ASP.NET project, I copied all dependent C++ DLLs to the "bin" folder of the ASP.NET project's output folder (same as for the workgin console application). While every C++ stuff has been compiled in Release mode, with the correct VC++ Redist Package installed, there should be all dependencies in place. Of course I know there is a FileNotFoundException, but I cannot work out what's missing...
As said: the same code for accessing the C++/CLI component works in a .NET 3.5 console application on both test PCs (where I have the same dependencies deployed) with the same dependent C++ DLLs deployed into the output folder, just in ASP.NET I get the above error.
Any suggestions how I can get rid of the problem or how I can track it further?
(Of course I searched StackOverflow and Google for the problem, e.g. I found these links, but they didn't help:
- "The specified module could not be found" error when running C# ASP.NET web service referring C++ dll
- Access x86 COM from x64 .NET
- ASP.NET application developed in 32 bit environment not working in 64 bit environment
- Module Not Found Exception From .NET 2.0 Web Service On Windows Server 2008 R2 )
ProcMon saved me.
The path was my problem too. It seems that IIS is creating a shadow copy of each managed dll in C:\Windows\System32\inetsrv folder. But this in not the case for unmanaged code. When it has to load an unmanaged dll, it search the environmental path and not the bin directory of the application in IIS.
Many thanks Aristos!!
Your code reach the _nLoad and this is good because have pass all checks for loading and move to the core to actually load the dll, and there its fail.
For start download the Dependency Walker
from http://www.dependencywalker.com/ and use it on dll to find out what other resource this dll needs to run. I suspect that can not load some other dll files.
Additional maybe this dll search for other files that can not find and thats why can not load. The second way is to use the File Monitor, or the Process Monitor from sysinternals to find what fail to load.
http://technet.microsoft.com/en-us/sysinternals
http://technet.microsoft.com/en-us/sysinternals/bb896645

asp.net publish problem

My application works fine on localhost. But when I publish it to the server , it throws the exception below.
It was working yesterday, but I added some simple file IO operations to global.asax and some other parts in code, i try to write log to some file in server side ..
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'MyApplication' or one of its dependencies. The system cannot find the file specified.]
System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName) +0
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) +78
System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) +58
System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +64
System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +51
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +38
My assumption would be that you haven't marked the target folder as an "application" is IIS, meaning it will be looking in the wrong place for the "bin" folder. You can do this in the IIS manager on the server; the folder should have a "cog" icon, indicating that it knows it is an application. If not: right-click on the folder and go into the properties; there should be a "Create Application" button (or similar). Also verify that ASP.NET is set to 2.0.* (on the ASP.NET tab).
(disclosure: there was a "moderator" flag suggesting this belongs on serverfault, but I disagree: knowing how to get an ASP.NET app working (even on a server) is a development issue)
is MyApplication.dll present in the bin folder? check it or give some details more about how you published the website

Couldn't load File or Assembly

I have a web application in .Net in which I use Ajax controls in some pages. Those pages are working in localhost, but when hosted, the pages in which Ajax included shows following error.
Server Error in '/Allforkids' Application.
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +58
System.Reflection.Assembly.VerifyCodeBaseDiscovery(String codeBase) +118
System.Reflection.Assembly.get_CodeBase() +35
System.Web.Handlers.ScriptResourceHandler.GetCodeBaseWithAssert(Assembly assembly) +31
System.Web.Handlers.ScriptResourceHandler.GetLastWriteTime(Assembly assembly) +36
System.Web.Handlers.ScriptResourceHandler.GetAssemblyInfoInternal(Assembly assembly) +61
System.Web.Handlers.ScriptResourceHandler.GetAssemblyInfo(Assembly assembly) +62
System.Web.Handlers.RuntimeScriptResourceHandler.System.Web.Handlers.IScriptResourceHandler.GetScriptResourceUrl(Assembly assembly, String resourceName, CultureInfo culture, Boolean zip, Boolean notifyScriptLoaded) +325
System.Web.Handlers.ScriptResourceHandler.GetScriptResourceUrl(Assembly assembly, String resourceName, CultureInfo culture, Boolean zip, Boolean notifyScriptLoaded) +33
System.Web.UI.ScriptManager.GetScriptResourceUrl(String resourceName, Assembly assembly) +89
System.Web.UI.ScriptRegistrationManager.RegisterClientScriptResource(Control control, Type type, String resourceName) +111
System.Web.UI.ScriptManager.RegisterClientScriptResource(Control control, Type type, String resourceName) +9
Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082
Can anybody give appropriate solution to get rid of this error?
This looks like something you need to bring up with your hosting provider. It would appear from the error that a configuration setting in the hosting server prohibits access to local files.
You could try adding this to your web.config:
<system.web>
...
<trust level="Medium" originUrl="" />
...
</system.web>
But, if the hosting provider has a setting in the machine.config that supersedes this, it will not make a difference. Here more information on that.
It could be security permissions on your folder/files. Are you writing to any files (like an Access DB)? Make sure your ASP.Net machine account (such as PCName\ASPNET) on the server has access to the folder.
Here is the code from the Assembly class:
private void VerifyCodeBaseDiscovery(String codeBase)
{
if ((codeBase != null) &&
(String.Compare( codeBase, 0, s_localFilePrefix, 0, 5, true, CultureInfo.InvariantCulture) == 0)) {
System.Security.Util.URLString urlString = new System.Security.Util.URLString( codeBase );
new FileIOPermission( FileIOPermissionAccess.PathDiscovery, urlString.GetFileName() ).Demand();
}
}
The exception is thrown on the .Demand() method asking for FileIOPermissionAccess.PathDiscovery to the file containing the script.
My guess is the IIS worker process does not have READ/BROWSE access to the path containing the script.
If you are registering your own scripts to the ScriptManager, check the filepath (usual rule of thumb, the scripts should not be in a parent (eg. ..\Scripts) folder).
If this exception trows on the AJAX Extensions script resources there might be a problem with the installation of the AJAX Extensions.You need to ask your hosting provider to check it.
PS. Is there more to the stack trace? It seems odd that the first call in the stack is "RegisterClientScriptResource".

SecurityException: Request for the permission of type AspNetHostingPermission failed

Setting up a new developing workstation, when I run the ASP.NET (MVC) application from Visual Studio 2008 I get a SecurityException. Any ideas what might be the problem?
I am accessing the data files over SMB (it's a shared mounted as Z:) and I've given full trust to it by running
caspol -m -ag 1 -url "\\server\share\" FullTrust -exclusive on
The full traceback is:
Server Error in '/' Application.
Security Exception
Description: The application attempted to perform an operation not allowed by
the security policy. To grant this application the required permission
please contact your system administrator or change the
application's trust level in the configuration file.
Exception Details:
System.Security.SecurityException:
Request for the permission of type 'System.Web.AspNetHostingPermission,
System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Source Error:
An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the exception
can be identified using the exception stack trace below.
Stack Trace:
[SecurityException: Request for the permission of type
'System.Web.AspNetHostingPermission, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Reflection.Assembly._GetType(String name, Boolean throwOnError, Boolean
ignoreCase) +0
System.Reflection.Assembly.GetType(String name, Boolean throwOnError, Boolean
ignoreCase) +42
System.Web.UI.Util.GetTypeFromAssemblies(ICollection
assemblies, String typeName, Boolean ignoreCase) +145
System.Web.UI.TemplateParser.GetType(String
typeName, Boolean ignoreCase, Boolean throwOnError) +73
System.Web.UI.TemplateParser.ProcessInheritsAttribute(String
baseTypeName, String codeFileBaseTypeName, String src,
Assembly assembly) +111
System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary
parseData) +279
Version Information: Microsoft .NET
Framework Version:2.0.50727.4927;
ASP.NET Version:2.0.50727.4927
Are you using a virtual directory that points to a remote share?
http://support.microsoft.com/?id=320268
Also take a look at "Troubleshooting common permissions and security-related issues in ASP.NET"
http://support.microsoft.com/?id=910449
Here's a command which worked for me:
C:\Windows\System32>C:\Windows\Microsoft.NET\Framework\v2.0.50727\caspol.exe -m -ag 1 -url "http://localhost/*" FullTrust

Resources