This issue had nothing to do with compiling the C# expressions since I was deploying the service under IIS and it handles the compilation. It was resolved after reading this Visual Studio Feedback article. My assignment activity value was written like this, and always threw an exception when the Random() function was included:
new ExpenseReportConfirmation() {
Amount = report.Amount,
City = report.City,
Client = report.Client,
Employee = report.Employee,
EndDate = report.EndDate,
StartDate = report.StartDate,
ReportID = new Random().Next(0, 50)
};
I re-wrote the expression to this and everything works:
new ExpenseReportConfirmation() { Amount = report.Amount, City = report.City, Client = report.Client, Employee = report.Employee, EndDate = report.EndDate, StartDate = report.StartDate, ReportID = new Random().Next(0, 50) };
PS: I was using the WCF Test Client to interact with my workflow service. When it catches an error, a large amount of text is dumped to the user, including the first 1024 bytes of the service response. It took me a while to learn to dig down past all that and find the internal exception. Here is an example of what to look for near the bottom of the text dump:
[ConfigurationErrorsException: The extension '.xalmx' is not registered with WCF/WF handler.