Search code examples
c#asp.netoffice-interop

Where and How to set 'Embed Interop Types' false in visual studio


I am a newbie to asp.net , and I'm using microsoft.office.interop.word dll for displaying word document, and it shows error as

Cannot embed interop type 'Microsoft.Office.Interop.Word.WdMailSystem' found in both assembly 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\d5b13769\135f0cf9\assembly\dl3\8de2cc60\9bee7a13_f7a7d001\microsoft.office.interop.word.DLL' and 'c:\Windows\assembly\GAC\Microsoft.Office.Interop.Word\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll'. Consider setting the 'Embed Interop Types' property to false.

and it will be helpfull if anyone helps me , thank you


Solution

  • There is no need to use the Embed Interop Types property for Office interops libs.

    Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

    If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. Read more about that in the Considerations for server-side Automation of Office article in MSDN.

    You may consider using the Open XML SDK, see Welcome to the Open XML SDK 2.5 for Office for more information. Or just find any third-party components designed for the server-side execution.