I m working in VS 2010 and working on upgrading our application to .NET 4. The application is built with Excel as the base and we want to take advantage of some of the improvements to .NET for using Excel. But I ran across a strange error that seems to be caused by using an Excel Interop object in a generic dictionary. Here is the error that was generated:
C:MyAppTheAssemblyMyClass.cs(823,57):
error CS1769: Type MyAppOtherAssemply.IMyController.SheetReports from assembly c:MyAppOtherAssemply.inDebugOtherAssembly.dll
cannot be used across assembly boundaries because it has a generic type
parameter that is an embedded interop type.
Here s the actual property that has the issue:
Dictionary<Excel.Worksheet, IReportSheet> SheetReports { get;}
Are we unable to use Interop objects in generic objects? If so, this is a serious limitation in .NET 4.0. I tried setting the Embed Interop property to false, but that didn t seem to change anything. Please let me know if there is any way around this.