none
Member Cannot be used across assembly boundaries because it contains a type which has a generic type parameter that is an embedded interop type. RRS feed

  • Question

  • Hi all,

    I am working on an Add-in project for Excel. This Addin contains a Ribbon item.

    I have migrated this project from .NET 3.5 to .NET4.0 and resolved problems related to ribbon designer generated code. this is the linke issue: https://social.msdn.microsoft.com/Forums/office/en-US/9ce47bad-2ac0-4884-947a-a0e1f8d75349/getting-errors-on-migrating-addins-ribbon-from-net-35-to-net4?forum=exceldev

    Then when I build my Add-in project I get a new error :

    The error is generated inside a function which handle the click event on a Ribbon button.

    This is my code: 

    private void ModifyTable_Click_1(object sender, RibbonControlEventArgs e) { try { Worksheet ws = Globals.ThisAddIn.Application.ActiveSheet as Worksheet;

    //Error is generated in this line List<PivotTable> selectedPts = AddinFunctionsTable.GetInstance().getPivotTablesSelected(ws); .... .... } catch (Exception ex) { } }

    Can you please help me?


    said

    Friday, October 23, 2015 3:07 PM

Answers

  • Hi said,

    >>Member Cannot be used across assembly boundaries because it contains a type which has a generic type parameter that is an embedded interop type.<<

    Based on the error message, it is relative to the return types. This is a limitation of the Common Language Runtime (CLR). If you are able to, you can resolve the issue by modifying the assembly that exposes the embedded type as a generic parameter. For example, we can change the result from List<PivotTable> to  IList<PivotTable>.

    Either we can modify the references to the PIA assembly to set Embed Interop Types to false.

    You can refer to link below for more detail about this issue.

    Troubleshooting Errors When Embedding Type Information (Doug Rothaus)

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by saidOuarrich Monday, October 26, 2015 10:52 AM
    Monday, October 26, 2015 7:02 AM
    Moderator
  • Hi Fei,

    Great.

    I changed the getPivotTablesSelected method return type to IList<PivotTable>. And then my code becomes like this: 

    IList<PivotTable> selectedPts = AddinFunctionsTable.GetInstance().getPivotTablesSelected(ws);

    Thank you for your help.


    said

    • Marked as answer by saidOuarrich Monday, October 26, 2015 11:48 AM
    Monday, October 26, 2015 11:00 AM

All replies

  • Hi said,

    >>Member Cannot be used across assembly boundaries because it contains a type which has a generic type parameter that is an embedded interop type.<<

    Based on the error message, it is relative to the return types. This is a limitation of the Common Language Runtime (CLR). If you are able to, you can resolve the issue by modifying the assembly that exposes the embedded type as a generic parameter. For example, we can change the result from List<PivotTable> to  IList<PivotTable>.

    Either we can modify the references to the PIA assembly to set Embed Interop Types to false.

    You can refer to link below for more detail about this issue.

    Troubleshooting Errors When Embedding Type Information (Doug Rothaus)

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by saidOuarrich Monday, October 26, 2015 10:52 AM
    Monday, October 26, 2015 7:02 AM
    Moderator
  • Hi Fei,

    Great.

    I changed the getPivotTablesSelected method return type to IList<PivotTable>. And then my code becomes like this: 

    IList<PivotTable> selectedPts = AddinFunctionsTable.GetInstance().getPivotTablesSelected(ws);

    Thank you for your help.


    said

    • Marked as answer by saidOuarrich Monday, October 26, 2015 11:48 AM
    Monday, October 26, 2015 11:00 AM