I just started playing around with WCF and stumbled upon an error while deploying a WCF host application to an IIS 5.1 instance running on XP-Pro.

My WCF app is held in a folder which is shared as a virtual folder in IIS on the target machine. It took a lot of googling to find a resolution and I had to take bits of information from a number of sources so for my sanity, I thought I'd blog it here for my future reference.

I got a server application unavailable error via the browser when trying to brows to a .svc file and the Event Viewer made three entries about the issue.

The first entry was a warning:

EventId : 1073 Failed to initialize the AppDomain:/LM/W3SVC/1/Root/ProductService Exception: System.IO.FileLoadException

Message: Could not load file or assembly 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Access is denied.

StackTrace: at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark) at System.Activator.CreateInstance(String assemblyName, String typeName) at System.AppDomain.CreateInstance(String assemblyName, String typeName) at System.AppDomain.CreateInstance(String assemblyName, String typeName) at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters) at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironmentAndReportErrors(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)

The second entry was an error

Failed to execute the request because the ASP.NET process identity does not have read permissions to the global assembly cache. Error: 0x80070005 Access is denied.

The third entry was an error

aspnet_wp.exe (PID: 3120) stopped unexpectedly.

To get around this I had to grant Read And Execute, Read & Write permissions to the application folder and propagate the permissions down to a child files and folders.

To access file and folder security in Windows XP, right click a folder and select properties.

If a security tab is not visible you must go into file explorer, Select Tools > Folder Options > View.

Deselect the check box for "Use simple file sharing". Select "Ok" and select properties on the app folder again.

This time, the Security tab will be visible and you can now select it and Add the ASPNET user to folder and grant them the rights listed earlier.

Select Advanced and ensure that "Inherit from the parent…." option is checked and hit "Ok".

Browsing to my WCF app now works fine and I can get back to work at last….. I hope this is useful.

Want to learn .net Core?

  • Want to learn .NET Core but don't know where to start?
  • Don't have time to keep up with everything Microsoft is putting out?
  • Stuck on legacy apps when you want to build something new?
Enter your details below and get my weekly update; learn how to build better .NET web apps.
comments powered by Disqus