2011-01-13 41 views
2

我需要將'System.XML.dll'程序集引用添加到web.config中(爲了嘗試解決問題,請在此處提到:Problem with Extension method: IXmlLineInfo)。如何從web.config引用程序集?

我試着將下面一行添加到「組件」部分:

<add assembly="System.Xml, Version=2.0.5.0, Culture=neutral, 
    PublicKeyToken=7cec85d7bea7798e"/> 

導致錯誤:

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Could not load file or assembly 'System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

說實話,我不知道,如果版本/文化/ PublicKeyToken指定正確。

我有幾個不同的版本system.xml.dll的的:

  • C:\ Program Files文件(x86)的\參考大會\微軟\ Framework.NETFramework \ v3.5版本\資料\客戶端\ SYSTEM。 XML.dll
  • C:\ Program Files(x86)\ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ Profile \ Client \ System.XML.dll
  • C:\ Program Files(x86)\ Reference大會\微軟\ Framework.NETFramework \ V4.0 \ system.xml.dll的
  • C:\ Program Files文件(x86)的\參考大會\微軟\框架\西爾夫rlight \ 3.0 \ system.xml.dll的
  • C:\ Program Files文件(x86)的\參考大會\微軟\框架\ Silverlight的\ V4.0 \ system.xml.dll的

我也有一些組件在GAC的框架,框架64,等等

問題1:

我需要哪個組件?

問題2:(過時)

如何確定確切的程序集的版本和公鑰?

P.S.有趣的事情,當我貼出的問題,我發現有一個「publickkeytoken」標籤已經和它包含答案問題2 :)

非常感謝!

+1

您可以輕鬆地通過[加載它來確定.NET程序集的完整簽名。NET Reflector](http://i.imgur.com/7BYX7.png)。作爲替代,您可以通過從Visual Studio命令提示符調用`sn -T `來獲取公鑰標記。 – 2011-01-13 16:51:09

回答

1

如果您正在使用Visual Studio,那麼你可以通過右擊做你的項目 - >添加參考 - >在.NET下標籤,你會發現該組件。

How to add assembly reference via VS

根據項目即網站或WebApplication的VS的類型要麼添加到web.config中的條目或DLL添加到您的bin文件夾。

現在您需要哪一個(2.0/3.5/4.0)取決於您的應用程序。

3

嘗試「GACUTIL/L」,並確保你在你的web.config把你真的要引用,根據目標的.NET版本(例如,3.5,4.0,等等)之一。 (在代碼方面,請確保您可以通過Assembly.Load()加載程序集)

+0

是的這項工作。您必須從開發人員命令提示符運行該命令。這不是在visual studio裏面,你必須去你的windows菜單轉到visual studio並打開Visual studio tool,裏面是開發人員命令提示符。 – freedeveloper 2016-03-21 15:41:23

相關問題