Page 118 - CSharp/C#
P. 118

[assembly: InternalsVisibleTo("MyAssembly.UnitTests")]


        This is especially useful for unit testing to prevent unnecessary public declarations.


        [AssemblyKeyFile]


        Whenever we want our assembly to install in GAC then it is must to have a strong name. For
        strong naming assembly we have to create a public key. To generate the .snk file.


        To create a strong name key file

                  1.  Developers command prompt for VS2015 (with administrator Access)
                  2.  At the command prompt, type cd C:\Directory_Name and press ENTER.
                  3.  At the command prompt, type sn -k KeyFileName.snk, and then press ENTER.


        once the keyFileName.snk is created at specified directory then give refernce in your project . give
        AssemblyKeyFileAttribute attribute the path to snk file to generate the key when we build our class
        library.

              Properties -> AssemblyInfo.cs


         [assembly: AssemblyKeyFile(@"c:\Directory_Name\KeyFileName.snk")]


        Thi will create a strong name assembly after build. After creating your strong name assembly you
        can then install it in GAC


        Happy Coding :)

        Read AssemblyInfo.cs Examples online: https://riptutorial.com/csharp/topic/4264/assemblyinfo-cs-
        examples







































        https://riptutorial.com/                                                                               64
   113   114   115   116   117   118   119   120   121   122   123