<p>Trying to use an excpetion class which could provide location reference for XML parsing, found an interesting behavior - compiler could not choose between overload which consumes an interface and one which needs System.Exception when I trying to pass XmlReader as a parameter.</p>

<p>Detais are following:</p>

<pre><code>//exception overloads:
public FilterXmlParseException(string message, Exception innerException)
        : base(message, innerException) { }
public FilterXmlParseException(string message, IXmlLineInfo lineInfo) {...}

//Usage:
XmlReader reader = ...
IXmlLineInfo lineinfo = (IXmlLineInfo)reader;

//fails
throw new FilterXmlParseException("&lt;Filter&gt; element expected", reader);

//ok
throw new FilterXmlParseException("&lt;Filter&gt; element expected", lineinfo);
</code></pre>

<p>And it fails since it could not select correct overload.But why? We see that XmlReader supports an interface and it is not inherited from System.Exception</p>

The line:
```
```
//fails
throw new FilterXmlParseException("<Filter> element expected", reader);
```
```
because XmlReader doesn't implement IXmlLineInfo. I am not sure if your cast works, but the casts are not checked statically. If it actually works, it is because the concrete class (that inherits from XmlReader) implements this interface, but the compiler has no way to know it.