<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # Compiler Error CS1705 程序集“AssemblyName1”所使用的“TypeName”的版本高于所引用的程序集“AssemblyName2”的版本 您要進入一個版本號高于所引用的程序集的版本號的類型。此錯誤通常由意外使用相同程序集的兩個版本引發。 例如,假設您有兩個程序集,Asmb1 和 Asmb2。程序集 Asmb1 引用生成程序集 Asmb2 1.0。程序集 Asmb1 還使用已添加到 2.0 版的程序集 Asmb2 的類 MyClass。編譯器有一致性綁定引用規則,對 2.0 版的MyClass的引用無法由 1.0 版滿足。 下面詳細示例由四個代碼模塊: * 兩個 DLL,它們除了版本特性外,其他方面都是一樣的。 * 引用前兩個的第三個 DLL。 * 引用相同的 DLL的1.0版本的客戶,但是,從版本 2.0 訪問的類。 下面的代碼創建兩個相同的 DLL 中的第一個。有關如何生成密鑰文件的信息,請參見 [/keyfile (C# Compiler Options)](https://msdn.microsoft.com/zh-cn/library/w2kyay38.aspx)。 ``` // CS1705a.cs // Compile by using the following command: // csc /target:library /out:C:\\CS1705.dll /keyfile:mykey.snk CS1705a.cs // The DLL is created in the C:\ directory. // The AssemblyVersion attribute specifies version 1.0 for this DLL. [assembly:System.Reflection.AssemblyVersion("1.0")] public class Class1 { public void Method1() {} } ``` 下面的代碼定義是程序集 2.0 版,由特性 [AssemblyVersionAttribute](https://msdn.microsoft.com/zh-cn/library/system.reflection.assemblyversionattribute.aspx) 指定。 ``` // CS1705b.cs // Compile by using the following command: // csc /target:library /out:CS1705.dll /keyfile:mykey.snk CS1705b.cs // The DLL is created in the current directory. // The AssemblyVersion attribute specifies version 2.0 for this DLL. [assembly:System.Reflection.AssemblyVersion("2.0")] public class Class1 { public void Method1() { } } ``` 下面的代碼引用前面的代碼中定義的兩個 DLL 版本。 AssemblyA 引用 CS1705 a.cs (版本 1.0)創建的 DLL。 AssemblyB 引用 CS1705b.cs (版本 2.0)創建的 DLL。兩個方法是在 ClassC 中定義的。第一,Return1A,它返回 Class1A類型的對象,是從 DLL 版本 1.0的Class1 的別名。第二,Return1B,它返回 Class1B類型的對象,是從 DLL 版本 2.0的Class1 的別名。 Return1A 的定義在版本 1.0 上創建一個依賴關系,這些依賴關系;Return1B 的定義在創建版本 2.0上創建一個依賴關系。 ``` // CS1705c.cs // Compile by using the following command. AssemblyA refers to the DLL created by // CS1705a.cs (version 1.0). AssemblyB refers to the DLL created by CS1705b.cs // (version 2.0). // csc /target:library /r:AssemblyA=C:\\CS1705.dll /r:AssemblyB=CS1705.dll CS1705c.cs extern alias AssemblyA; extern alias AssemblyB; // Class1A is an alias for type Class1 from VS1705a.cs, which is in version 1.0 // of the assembly. Class1B is an alias for type Class1 from CS1705b.cs, which // is in version 2.0 of the assembly. using Class1A = AssemblyA::Class1; using Class1B = AssemblyB::Class1; // Method Return1A in ClassC returns an object of type Class1A, which is // Class1 from version 1.0 of the DLL. Method Return1B returns an object // of type Class1B, which is Class1 from version 2.0 of the DLL. public class ClassC { // The following line creates a dependency on version 1.0 of CS1705.dll. // This is not the source of the problem when ClassC is accessed from // CS1705d.cs because CS1705d.cs references version 1.0 of the DLL. // Therefore, type Class1A and the assembly have the same version. public static Class1A Return1A() { return new Class1A(); } // The following line creates a dependency on version 2.0 of CS1705.dll. // This causes compiler error CS1705 when ClassC is accessed from // CS1705d.cs, because CS1705d.cs does not reference version 2.0 of the // DLL. Class1B is the alias for Class1 in version 2.0, and CS1705d.cs // references version 1.0. public static Class1B Return1B() { return new Class1B(); } } ``` 下面的代碼可生成編譯器錯誤CS1705。它引用CS1705 a.cs (版本 1.0)創建的DLL 。但是,在 Main 方法中,代碼從CS1705 c.cs 的 ClassC來訪問 。 ClassC 使用在CS1705 b.cs(2.0 版)中定義的類型 。這導致編譯器錯誤 CS1705,因為類型具有高于引用的CS1705.dll的版本號的CS1705 的 .dll 的版本號。 ``` // CS1705d.cs // Compile by using the following command: // csc /reference:C:\\CS1705.dll /reference:CS1705c.dll CS1705d.cs // C:\\CS1705.dll is version 1.0 of the assembly. class Tester { static void Main() { // Return1A returns a type defined in version 1.0. ClassC.Return1A().Method1(); // Return1B returns a type defined in version 2.0. ClassC.Return1B().Method1(); } } ``` 可以通過以下方式之一來解決 這個錯誤: * 更新代碼,以便所有 DLL 文件使用的版本相同。 * 使用以下命令編譯,把對 DLL 2.0 版的引用添加到 d.cs CS1705: csc /reference:C:\\CS1705.dll /reference:CS1705.dll /reference:CS1705c.dll CS1705d.cs 雖然使用此命令時程序在編譯,則在不運行。為了使程序在運行,則可提供包含使用[&lt;assemblyIdentity&gt;和](https://msdn.microsoft.com/zh-cn/library/b0yt6ck0.aspx)[&lt;codeBase&gt;](https://msdn.microsoft.com/zh-cn/library/efs781xb.aspx) 子元素來指定 DLL1.0 版本位置的 [&lt;dependentAssembly&gt; 元素](https://msdn.microsoft.com/zh-cn/library/0ash1ksb.aspx)的應用程序配置文件。有關配置文件的更多信息,請參見[使用配置文件配置應用](https://msdn.microsoft.com/zh-cn/library/1xtk877y.aspx)。 ## 請參閱 [外部別名(C# 參考)](https://msdn.microsoft.com/zh-cn/library/ms173212.aspx) [:: 運算符(C# 參考)](https://msdn.microsoft.com/zh-cn/library/htccxtad.aspx) [Command-line Building With csc.exe](https://msdn.microsoft.com/zh-cn/library/78f4aasd.aspx)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看