We are maintaining a Kentico 11-based site (.NET Framework 4.6.1 running on IIS 10/Windows Server 2019). In testing code that throws an Exception derived directly from System.Exception, the system throws HttpCompileException with this message:
C:\<path>\B2CTokenProcessor.ascx.cs(28): error CS0155: The type caught or thrown must be derived from System.Exception
This is B2CTokenProcessor.ascx.cs line 28:
catch (IdTokenException x)
and this is the definition of IdTokenException:
public class IdTokenException : System.Exception
{
public IdTokenException(string message) : base(message) { }
}
In a situation this simple, an error like this is entirely baffling to me. If the definition of IdTokenException were missing or unreachable, I'd expect to see a type could not be found message (though, in fact, when I substitute an undefined name in that catch no error is logged by the CMS or in the Event Log). The only thought I have at all is that IdTokenException is defined in a NuGet package that was imported into the project; this Exception is not raised on the development site, but happens on a test site to which the site project and NuGet package DLLs have been deployed.
Why is .NET not seeing this type as being derived from System.Exception?