InternalsVisibleTo causes CS0246 error: The Type or Namespace could not be found

旧街凉风 提交于 2019-12-10 09:05:41

问题


I am trying to enable one assembly to access another assembly's internal classes by adding

[assembly:InternalsVisibleTo("assembly-name")]

to the second assembly. However, this causes the following error:

error CS0246: The type or namespace name 'InternalsVisibleTo' could not be found (are you missing a using directive or an assembly reference?)

I am following the examples here: MSDN Reference

What am I doing wrong?


回答1:


Make sure you import System.Runtime.CompilerServices. Or use a fully qualified name.

[assembly:System.Runtime.CompilerServices.InternalsVisibleTo("assembly-name")]


来源:https://stackoverflow.com/questions/1269118/internalsvisibleto-causes-cs0246-error-the-type-or-namespace-could-not-be-found

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