I figured it out. The issue is that, for some reason, the compiler cannot find the assembly with the custom ExpressionBuilder
. What fixed the problem was to use a Partial Assembly Reference with slightly more information than just the class name and namespace in the add
tag:
<system.web>
<compilation debug="true">
<!-- Skipping the 'assemblies' and 'buildProviders' areas -->
<expressionBuilders>
<add expressionPrefix="MyCustom" type="MyWebApplication.MyCustomExpressionBuilder, MyWebApplication" />
</expressionBuilders>
</compilation>
<!-- other stuff -->
In other words, change the type
attribute to specify both the class name (with namespace) and the name of the assembly. Note that specifying any more additional information causes a different error (even the version number, and even if the version number is correct).
As to how I found out, a good tip for solving these problems is to enable logging as described here. For VS2008, you would use regedit
to:
- Go to
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0
- Create a new key named
WebApplicationProjects
if it does not exist. Then, select it. - Create a new key named
Debug
if it does not exist. Then, select it. - Add a new string called
LogFile
. The value should be a path to which VS2008 will have write permissions (so, potentially not a file in the root of C:). Make sure to escape any backslashes, likeC:\\PathICanWrite\\vslogfile.txt
. - Add a new DWORD called
Enabled
, and set it to 1. - Add a new DWORD called
LogFieldGeneratorFailures
, and set it to 1. - Restart VS2008.
When I looked at the log file, I was able to use the stack trace to determine that I had an assembly load problem, which now seems obvious. A message in the log gives a further tip to resolve assembly load issues:
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].
I found that I needed to restart the machine for the new registry setting to take effect. Then, additional assembly binding information was available in the log.