Assembly added via Add Reference not copied to output directory unless referred to in code

久未见 提交于 2019-12-04 23:48:11

If you deploy/copy an application that contains a reference to a custom component that is registered in the GAC, the component will not be deployed/copied with the application, regardless of the Copy Local setting. See MSDN

You have to force copy local to true by adding Private metadata to the GAC assembly reference. Edit your project file and add Private metadata:

<Reference ..>
    <Private>True</Private>
</Reference ..>

<ProjectReference ..>
    <Private>True</Private>
</ProjectReference ..>

Now your GAC assembly should be copied/dropped from the output folder.

Aha.. the referenced assembly targeted .NET Framework 4.0, but the referencing assembly was targeting the Client Profile version of .NET 4.0.

The reference was added, appeared, no problems or warnings at all (from the UI or VS at least), but I couldn't refer to it in code, and it wouldn't appear in the output.

If anyone has ideas why this went undetected, perhaps they could let me know?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!