Adrian gave an almost correct answer, but there is a better way to deal with this error. Do not turn off the built-in interaction types, but use the common interface instead:
IDictionary<Excel.Worksheet, IReportSheet> SheetReports { get;}
CLR 4.0 introduced the concept of type equivalence. If we simplified this a bit, we could say that CLR 4.0 treats two identically named interface types with identical Guid attributes as if they were the same type. The notion that type equivalence is very deeply embedded in the system and does work with equivalent types as if it were a single type. A few examples; 1. You can use reflection to invoke an interface method on an object that implements an equivalent interface. 2. Instances of common interfaces parameterized on equivalent interfaces are also considered equivalent.
C # and VB compilers use this function to implement the Insert Interrupt Types function.
Now to the exceptions: 1. Comparative comparisons between equivalent System.Type interfaces will fail, because there are still two different types in the type system:
typeOfWorkbookFromAssemblyA.Equals(typeOfWorkbookFromAssemblyB) == false
but there is a new Type.IsEquivalentTo API
typeOfWorkbookFromA.IsEquivalentTo(typeOfWorkbookFromB) == true
- Two instances of the same generic class parameterized on equivalent interfaces are not considered equivalent.
Hope this helps.
source share