Yossi Dahan [BizTalk]

Google
 

Saturday, January 28, 2006

Compilation error with the ParameterDeclarationCollection item value and ToString

This must be a beta-related issue, and I'm sure it's going to disappear quite soon, but I've banged my head against the wall enough times last night to tell me this might be worth something to someone else.

I've finally made some time to play with the Windows Workflow Foundation extension to Visusl Studio 2005.

Following a very simple set of examples laid out in this great walk-through I quickly got comfortable with it...
Only that I wasn't following it very closely.

I took this part of an example -
public string UserFirstName
{
get { return (string) Parameters["FirstName"].Value; }
set { Parameters["FirstName"].Value = value; }
}
and wrote it like this -
public string UserFirstName
{
get { return Parameters["FirstName"].Value.ToString(); }
set { Parameters["FirstName"].Value = value; }
}
To save you the time spotting the difference - the example from the article uses - "return (string)parameters" and I'm using "return parameters.ToString()"

Now - you would assume the two are identical. I've never expected a difference in behaviour between them. But the latter causes a compliation error - "error 348: Compilation failed. Exception has been thrown by the target of an invocation."

And the most annoying thing - it does not provide any indication to where the problem is. no line number, no double-click-takes-me-there. nothing. took me a good night sleep and slowly re-building the example to find out the cause (and be really surprised by it)