InternalsVisibleTo attribute isn't working

后端 未结 19 2489
眼角桃花
眼角桃花 2020-11-27 13:51

I am trying to use the InternalsVisibleTo assembly attribute to make my internal classes in a .NET class library visible to my unit test project. For some reas

19条回答
  •  爱一瞬间的悲伤
    2020-11-27 13:59

    If your assemblies aren't signed, but you are still getting the same error, check your AssemblyInfo.cs file for either of the following lines:

    [assembly: AssemblyKeyFile("")]
    [assembly: AssemblyKeyName("")]
    

    The properties tab will still show your assembly as unsigned if either (or both) of these lines are present, but the InternalsVisibleTo attribute treats an assembly with these lines as strongly signed. Simply delete (or comment out) these lines, and it should work fine for you.

提交回复
热议问题