Wednesday, January 9, 2013

TFS Build Error: Type XXX not visible. If the type is local...

Error message looks something like this:

Type 'System.Linq.OrderedEnumerable`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' not visible. If the type is local, please set the LocalAssembly field in XamlReaderSettings.

The problem appears if you have some variable which is visible (NB! visible, not used!) in different scopes, and one of them is AgentScope. Then a scope where the variable is not used, but visible might not be able to resolve the type.

For example, I have sequence - Main. Under it I have AgentScope. I declare a variable MyList of type StringList and set visibility to Main. Right, everybody should be able to see MyList!...

I use MyList in Main -> so it's type (StringList) belongs to used types and the corresponding assembly is imported.
So we move to agent scope. I do not use MyList on agent scope, so StringList doesn't end up in the list of used types => corresponding assembly is not loaded on agent. But visibility says - AgentScope must know about MyList (since it is under Main), so AgentScope tries to see the variable - but no type StringList is known on agent -> kabum!

Solution is easy - set scope of variables limited to their usage. In my case I created sub-sequence, where I use MyList and limit scope to it.

No comments:

Post a Comment