I'm working in VS 2010 and working on upgrading our application to .NET 4. The application is build 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:\MyApp\TheAssembly\MyClass.cs(823,57):
error CS1769: Type 'MyApp\OtherAssemply.IMyController.SheetReports' from assembly 'c:\MyApp\OtherAssemply.\bin\Debug\OtherAssembly.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 anyway around this.
Cheers!
Erick