Bizarre errors... [fatal error X1001: unknown system exception]
In an earlier post (here) I discussed a truly bizarre error received when trying to compile an orchestration. Well at least on that occasion it gave me SOME information, it might've been cryptic but at least I has somewhere to start chasing the ghost ...
Today I got what must rank as the most obscure and useless error message I have ever received during BizTalk development, or any development for that matter.
Let me explain ...
See if you can spot what caused the exception before getting to my explanation of it. Once you see the explanation it's like Doh! [done in best Holmer Simpson voice]
So I've been working on this "little" orchestration for some time now which is exposed as a web service indirectly through it's schemas, as per accepted best practices for exposing web services. No biggie there.
I've also defined a standard Service Response message that my services return which looks a little like this:
<ServiceResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MessageDateTime>2001-12-17T09:30:47.0Z</MessageDateTime>
<Error>true</Error>
<Messages>
<Message>Some error message goes here</Message>
<Message>Some other message</Message>
</Messages>
</ServiceResponse>
Great,
So then I proceeded to build a simple helper class in .NET so I could build up one of these beauties dynamically inside my orchestration. This helper class looked like this:
For brevity I've removed the fluff and only left stuff that is applicable to this post
namespace MessageHelpers
{
public partial class ServiceResponse
{
private System.DateTime messageDateTimeField;
private bool errorField;
private ServiceResponseMessageList messagesField = new ServiceResponseMessageList();
[XmlArrayItem(ElementName = "Message", IsNullable=true)]
public ServiceResponseMessageList Messages
{
get { return this.messagesField; }
set { this.messagesField = value; }
}
public XmlDocument ToXmlDocument()
{
XmlDocument doc = new XmlDocument();
XmlSerializer serializer = new XmlSerializer(typeof(ServiceResponse));
StringBuilder sb = new StringBuilder();
serializer.Serialize(new StringWriter(sb, CultureInfo.InvariantCulture), this);
doc.LoadXml(sb.ToString());
return doc;
}
}
public class ServiceResponseMessageList : IList<string>
{
public override string ToString()
{
StringBuilder builder = new StringBuilder();
foreach (string item in this)
{
builder.AppendLine(item);
}
return builder.ToString();
}
}
}
So this is simple enough ...
Wrote my tests, tested it and it all worked really nicely.
I then added a local variable to my orchestration of type ServiceResponseMessageList with the intention of doing something like shown below in a message assignment shape to build up my response message
Happiness ... or so I thought.
I hit Ctrl + B and Visual Studio cranked away for ages and eventually threw the following:
------ Build started: Project: AMH.Integration.Integer.BizTalk.Orchestrations, Configuration: Deployment .NET ------
Updating references...
Performing main compilation...
fatal error X1001: unknown system exception
There's the beauty in all it's glory!
fatal error X1001
Unkown system exception
Man Alive!
Have you spotted it yet? It's actually quite obvious, once you know where to look.
Got it? Given up?
Well we all know that BizTalk 2006 doesn't know about System.Collections.Generics right ...
Ok there's a massive hint 
The ServiceResponseMessageList class inherits from a List<string>. Hmmm. Doh!
Adding a variable of this type to my orchestration is what caused this subtle piece of brilliance to appear.
Look, I know it was my fault entirely for writing ridiculous code, but why oh why can we not have decent, descriptive and informative error messages ? Is this too much to ask ?
A decent descriptive error message along the lines of
"adding a variable of type X that inherits from System.Collections.Generics is not supported"
would've saved me a few hours of ripping out my non-existent hair!