home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / QuickStart / howto / doc / sharedname.aspx < prev    next >
Encoding:
Text File  |  2000-06-09  |  2.9 KB  |  60 lines

  1.  
  2. <!-- #include virtual="/quickstart/howto/include/header.inc" -->
  3.  
  4. <%
  5.     runsample = Server.MapPath("/quickstart/howto/samples/assemblies/sharedname")
  6.     icon = "/quickstart/images/genicon.gif"
  7.     caption = "Build.bat"
  8. %>
  9.  
  10. <h4>How Do I...create an assembly with a shared name?</h4>
  11.  
  12. <div class="indent" style="WIDTH: 660px">
  13. This sample demonstrates how to create an assembly with a shared name...
  14. </div>
  15.  
  16. <h4>Example</h4>
  17.  
  18. <p>
  19. <div class="indent">
  20. <a target="_blank" href="<%=runsample%>">
  21. <img style="border-color:black" border=1 src="<%=icon%>"><br>
  22. </a>
  23. <div class="caption"><%=caption%></div><br>
  24. </div>
  25.  
  26. <h4>Shared Names</h4>
  27. <div class="indent" style="WIDTH: 660px">
  28. <P>Shared names are used to provide name uniqueness and to prevent name spoofing 
  29. in the NGWS runtime.  If you are deploying an assembly that will be shared among many 
  30. applications on the same machine, it must have a shared name.  Even if you 
  31. will only use the assembly within your application, you may want to give it a 
  32. shared name as well.  In this way you can ensure that the assembly you 
  33. shipped as part of your app is in fact the exact one that gets loaded, i.e 
  34. someone didn't substitute a similar assembly, either maliciously or by accident, 
  35. for yours.</P>
  36. <P>The first step in building an assembly with a shared name is to get a 
  37. key-pair. Depending on your scenario you may have a secured key pair that is 
  38. used throughout your organization, or you may use a test or temporary key pair. 
  39. Details on these options and Shared names in general are available in the Shared 
  40. Name Spec in the NGWS SDK. </P>
  41. <P>This sample uses a test key in a file called TestKey.snk. TestKey.snk was 
  42. generated with the SN utility that ships in the SDK: </P>
  43. <P>sn -k Testkey.snk </P>
  44. <P>After you've obtained a key pair you need to add the proper switches so the 
  45. compiler emits the assembly with a strong name. These switches vary by compiler. 
  46. For this sample, the C# compiler is used with the /a.keyfile switch: </P>
  47. <P>csc /dll /a.keyfile:Testkey.snk sharedname.cs </P>
  48. <P>There are also options available to do a "partial sign", meaning that the 
  49. space for the signature is reserved in the PE file, but the signing itself is 
  50. not done until a later step. This approach is typically used if you don't have 
  51. access to the private key you'll need to generate the shared name. More details 
  52. on how these options work can be found in the Shared Name Spec. </P>
  53. <P>The batch file that ships with this sample runs SN to generate a key pair, 
  54. builds a shared named assembly with C#, then dumps the metadata and displays it 
  55. in a file.  By looking at the "Originator" field in the output file, you 
  56. can see the public key used to generate the shared name.  The signature 
  57. blob itself is stored elsewhere in the PE file.</P>
  58.                      
  59. </div><!-- #include virtual="/quickstart/howto/include/footer.inc" -->
  60.