dbLinq XMlMappingSource.cs contains code:
public void ReadEmptyContent(XmlReader r, string name)
{
if (r.IsEmptyElement)
r.ReadStartElement(name, DbmlNamespace);
else
{
r.ReadStartElement(name, DbmlNamespace);
for (r.MoveToContent(); r.NodeType != XmlNodeType.EndElement; r.MoveToContent())
{
if (r.NamespaceURI != DbmlNamespace)
r.Skip();
throw UnexpectedItemError(r);
}
r.ReadEndElement();
}
}
This causes compile warning
Warning CS0162 Unreachable code detected
at line
for (r.MoveToContent(); r.NodeType != XmlNodeType.EndElement; r.MoveToContent())
in third part of for clause r.MoveToContent()
It looks like normal node traversal code and third part of for is reached.
How to fix this ? Using .NET 4
As Rawling stated you are throwing the exception no matter what.
Try changing the loop to this:
for (r.MoveToContent(); r.NodeType != XmlNodeType.EndElement; r.MoveToContent())
{
if (r.NamespaceURI != DbmlNamespace)
r.Skip();
else
throw UnexpectedItemError(r);
}
This will fix your issue.