參看:http://msdn.microsoft.com/zh-cn/library/cc656912.aspx
在VS2010 中,你默認(rèn)建立的 WPF 程序就是.Net Framework 4 Client Profile ,而不是.Net Framework 4。昨天下午到今天早上,我在為 System.Web 無法引用而苦惱的問題,就是它導(dǎo)致的。
VS2010中,我們?cè)陧?xiàng)目的屬性下,可以看到項(xiàng)目有以下多種 Target framework 屬性。
我今天碰到的 Sytem.Web 引用問題如下:
在用 VS2010 Beta2 書寫一個(gè)WPF應(yīng)用的時(shí)候,要使用 System.Web.HttpUtility.UrlEncode()方法時(shí),發(fā)現(xiàn)竟然無法增加對(duì) System.Web 的引用。如下圖:
.NET Reference 中沒有 System.Web 組件。
使用 Browse 方式打開指定目錄的文件 C:\Windows\Microsoft.NET\Framework\v4.0.21006\System.Web.dll 也不行。
如下圖:
GAC 中也沒有 4.0 版本的 System.Web 組件,如下圖:
強(qiáng)制添加 C:\Windows\Microsoft.NET\Framework\v4.0.21006\System.Web.dll 到GAC 時(shí)會(huì)報(bào)錯(cuò)誤:
---------------------------
Cannot Add Assembly
---------------------------
Unable to add the selected assembly. The assembly must have a strong name (name, version and public key).
---------------------------
確定
---------------------------
這個(gè)文件的信息如下:
但是VS2010 Beta2 建立的 Web 項(xiàng)目,默認(rèn)就有 System.Web 的引用,這里沒有任何問題,如下圖:
查看這時(shí)候的 System.Web 屬性,如下:
把 C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web.dll 放入 GAC也會(huì)報(bào)錯(cuò)誤:
---------------------------
Cannot Add Assembly
---------------------------
Unable to add the selected assembly. The assembly must have a strong name (name, version and public key).
---------------------------
確定
---------------------------