What's the difference setting Embed Interop Types true and false in Visual Studio?

后端 未结 2 1831
醉酒成梦
醉酒成梦 2020-11-29 22:05

In Visual Studio, when adding one reference to the project, the properties window has an option Embed Inteop Types, should we set it to True or

2条回答
  •  星月不相逢
    2020-11-29 22:37

    This option was introduced in order to remove the need to deploy very large PIAs (Primary Interop Assemblies) for interop.

    It simply embeds the managed bridging code used that allows you to talk to unmanaged assemblies, but instead of embedding it all it only creates the stuff you actually use in code.

    Read more in Scott Hanselman's blog post about it and other VS improvements here.

    As for whether it is advised or not, I'm not sure as I don't need to use this feature. A quick web search yields a few leads:

    • Check your Embed Interop Types flag when doing Visual Studio extensibility work
    • The Pain of deploying Primary Interop Assemblies

    The only risk of turning them all to false is more deployment concerns with PIA files and a larger deployment if some of those files are large.

提交回复
热议问题