InternalsVisibleTo导致CS0246错误:找不到类型或命名空间 [英] InternalsVisibleTo causes CS0246 error: The Type or Namespace could not be found

查看:104
本文介绍了InternalsVisibleTo导致CS0246错误:找不到类型或命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过添加使一个程序集访问另一个程序集的内部类

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?)

我在这里遵循以下示例: MSDN参考

I am following the examples here: MSDN Reference

我在做什么错了?

推荐答案

确保导入System.Runtime.CompilerServices.或使用完全限定的名称.

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

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

这篇关于InternalsVisibleTo导致CS0246错误:找不到类型或命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆