<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>程序集 on 墨山灼海 | 个人技术分享站</title>
    <link>https://moshanzhuohai.com/tags/%E7%A8%8B%E5%BA%8F%E9%9B%86/</link>
    <description>Recent content in 程序集 on 墨山灼海 | 个人技术分享站</description>
    <generator>Hugo</generator>
    <language>zh-Hans-CN</language>
    <managingEditor>1009840925@qq.com (墨山灼海)</managingEditor>
    <webMaster>1009840925@qq.com (墨山灼海)</webMaster>
    <lastBuildDate>Wed, 25 Feb 2026 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://moshanzhuohai.com/tags/%E7%A8%8B%E5%BA%8F%E9%9B%86/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>C# - 友元程序集</title>
      <link>https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/</link>
      <pubDate>Wed, 25 Feb 2026 00:00:00 +0000</pubDate><author>1009840925@qq.com (墨山灼海)</author>
      <guid>https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/</guid>
      <description>&lt;h2 id=&#34;目录&#34;&gt;目录&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#%e7%9b%ae%e5%bd%95&#34;&gt;目录&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#1-%e6%a6%82%e8%bf%b0&#34;&gt;1. 概述&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#2-%e5%88%9b%e5%bb%ba%e9%a1%b9%e7%9b%ae&#34;&gt;2. 创建项目&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#21-%e6%b5%81%e7%a8%8b&#34;&gt;2.1. 流程&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#211-%e5%88%9b%e5%bb%ba%e7%a8%8b%e5%ba%8f%e9%9b%86&#34;&gt;2.1.1. 创建程序集&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#2111-%e5%88%9b%e5%bb%ba%e6%ba%90%e7%a8%8b%e5%ba%8f%e9%9b%86&#34;&gt;2.1.1.1. 创建源程序集&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#2112-%e5%88%9b%e5%bb%ba%e7%9b%ae%e6%a0%87%e7%a8%8b%e5%ba%8f%e9%9b%86&#34;&gt;2.1.1.2. 创建目标程序集&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#212-%e5%bc%95%e7%94%a8%e7%a8%8b%e5%ba%8f%e9%9b%86&#34;&gt;2.1.2. 引用程序集&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#213-%e7%bc%96%e8%af%91%e8%bf%90%e8%a1%8c%e6%b5%8b%e8%af%95&#34;&gt;2.1.3. 编译运行测试&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#2131-%e8%b0%83%e7%94%a8%e6%ba%90%e7%a8%8b%e5%ba%8f%e9%9b%86%e7%9a%84%e5%85%ac%e5%bc%80%e5%87%bd%e6%95%b0&#34;&gt;2.1.3.1. 调用源程序集的公开函数&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#2132-%e8%b0%83%e7%94%a8%e6%ba%90%e7%a8%8b%e5%ba%8f%e9%9b%86%e7%9a%84%e7%a7%81%e6%9c%89%e5%87%bd%e6%95%b0&#34;&gt;2.1.3.2. 调用源程序集的私有函数&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#3-%e6%b7%bb%e5%8a%a0%e6%9c%aa%e7%ad%be%e5%90%8d%e7%9a%84%e5%8f%8b%e5%85%83%e7%a8%8b%e5%ba%8f%e9%9b%86&#34;&gt;3. 添加未签名的友元程序集&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#31-%e5%89%8d%e6%8f%90%e6%9d%a1%e4%bb%b6&#34;&gt;3.1. 前提条件&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#32-%e6%b5%81%e7%a8%8b&#34;&gt;3.2. 流程&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#321-%e6%8c%87%e5%ae%9a%e7%9b%ae%e6%a0%87%e7%a8%8b%e5%ba%8f%e9%9b%86&#34;&gt;3.2.1. 指定目标程序集&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#3211-%e5%88%9b%e5%bb%ba%e8%84%9a%e6%9c%ac&#34;&gt;3.2.1.1. 创建脚本&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#3212-%e6%b7%bb%e5%8a%a0%e7%89%b9%e6%80%a7&#34;&gt;3.2.1.2. 添加特性&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#322-%e7%bc%96%e8%af%91%e8%bf%90%e8%a1%8c%e6%b5%8b%e8%af%95&#34;&gt;3.2.2. 编译运行测试&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#4-%e6%b7%bb%e5%8a%a0%e5%b7%b2%e7%ad%be%e5%90%8d%e7%9a%84%e5%8f%8b%e5%85%83%e7%a8%8b%e5%ba%8f%e9%9b%86&#34;&gt;4. 添加已签名的友元程序集&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#41-%e5%89%8d%e6%8f%90%e6%9d%a1%e4%bb%b6&#34;&gt;4.1. 前提条件&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#42-%e6%b5%81%e7%a8%8b&#34;&gt;4.2. 流程&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#421-%e6%8c%87%e5%ae%9a%e7%9b%ae%e6%a0%87%e7%a8%8b%e5%ba%8f%e9%9b%86&#34;&gt;4.2.1. 指定目标程序集&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#422-%e5%88%9b%e5%bb%ba%e5%af%86%e9%92%a5%e5%af%b9&#34;&gt;4.2.2. 创建密钥对&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#4221-%e6%89%93%e5%bc%80%e5%91%bd%e4%bb%a4%e8%a1%8c&#34;&gt;4.2.2.1. 打开命令行&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#4222-%e7%94%9f%e6%88%90%e5%af%86%e9%92%a5%e5%af%b9&#34;&gt;4.2.2.2. 生成密钥对&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#4223-%e5%88%9b%e5%bb%ba%e5%85%ac%e9%92%a5&#34;&gt;4.2.2.3. 创建公钥&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#4224-%e6%98%be%e7%a4%ba%e5%85%ac%e9%92%a5&#34;&gt;4.2.2.4. 显示公钥&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#423-%e6%b7%bb%e5%8a%a0%e5%bc%ba%e7%ad%be%e5%90%8d&#34;&gt;4.2.3. 添加强签名&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#424-%e6%8c%87%e5%ae%9a%e5%85%ac%e9%92%a5&#34;&gt;4.2.4. 指定公钥&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#425-%e7%bc%96%e8%af%91%e8%bf%90%e8%a1%8c%e6%b5%8b%e8%af%95&#34;&gt;4.2.5. 编译运行测试&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://moshanzhuohai.com/posts/csharp/knowledge/csharp-knowledge-friend-assembly/#%e5%8f%a6%e8%af%b7%e5%8f%82%e8%a7%81&#34;&gt;另请参见&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id=&#34;1-概述&#34;&gt;1. 概述&lt;/h2&gt;
&lt;p&gt;　　如果定义目标 C# 程序集为友元程序集，目标程序集可以正常访问源 C# 程序集中的所有内部成员（包括 &lt;code&gt;internal&lt;/code&gt;、&lt;code&gt;internal protected&lt;/code&gt; 和 &lt;code&gt;private protected&lt;/code&gt; 修饰的类型或类型成员）。&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
