I have an ASP.NET MVC 4 app with a .ashx for handling specific requests.
I’ve deployed this application successfully on dozens of different servers for different customers in a variety of different environments (Windows Server 2008, 2012, 2016 etc) and different versions of .NET (4.5, 4.5.1, 4.6.1 etc)
This customer currently has the application deployed successfully on their Server 2008 R2 box. However, on the 2012 R2 (IIS 8) server they are migrating to, the .ashx file WILL NOT compile.
At the top of the .ashx file we have a bunch of using directives for namespaces in the .NET Framework. As soon as we get to the using statements for any 3rd party namespaces, there’s a yellow screen with an error from csc.exe that the type or namespace of “ThirdPartyLib” cannot be found (make sure you aren’t missing a reference or a using directive)
.ashx file sample
using System; using System.IO; using System.Web; //etc using ThirdPartyLib.CustomThing;
The yellow screen says this:
CS0246: The type or namespace ‘ThirdPartyLib’ could not be found (are you missing a using directive or an assembly reference?)
Line 17: using System.Web;
Line 18: using ThirdyPartyLib.CustomThing;
Source File: C:\%PATH_TO_ASHX_FILE% Line: 18
Farther down the yellow screen page, we see the detailed compiler output
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" /t:library /utf8output /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Helpers\v4.0_22.214.171.124__31bf3856ad364e35\System.Web.Helpers.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_126.96.36.199__b77a5c561934e089\System.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_188.8.131.52__b77a5c561934e089\System.Core.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.Web\v4.0_184.108.40.206__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_220.127.116.11__b77a5c561934e089\System.Xml.Linq.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Routing\v4.0_18.104.22.168__31bf3856ad364e35\System.Web.Routing.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activation\v4.0_22.214.171.124__31bf3856ad364e35\System.ServiceModel.Activation.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_126.96.36.199__b77a5c561934e089\System.Service
Mind you, this works on every other customer environment we’ve deployed to.
One thing I noticed is that there are no arguments passed into the
csc.exe command that includes any of the custom types that are needed.
This brings me to my main question
Is there a way to get the compiler flags for the .ashx file on a server where this is working? I’d like to investigate this as the next troubleshooting step, but am unsure how.
For completeness, here are other things we’ve tried:
- Making sure file access is allowed for the app pool on the bin directory
- Registering the ThirdPartyLib.dll with
gacutil(albeit unsuccessfully due to a strong name error that I didn’t want to chase down farther)