自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Visual Studio 2010 RC關(guān)于WPF開發(fā)多個不同

開發(fā) 后端
本文將繼續(xù)討論Visual Studio 2010 RC關(guān)于WPF開發(fā)多個不同,希望通過本文能讓大家對VS 2010有更深的了解。

本文是《辨析Visual Studio 2010 RC中WPF開發(fā)的改進(jìn)》的續(xù)篇,將繼續(xù)講述Visual Studio 2010 RC在WPF方面的改進(jìn)。

本不該在這個元宵佳節(jié)里寫隨筆。在這花好月圓時(shí)刻應(yīng)該把酒當(dāng)歌,莫使金樽空對月。特別是即汶川,海地之后的智利8.8級地震,更加讓我嗅到了2012的味道。

但是千不該,萬不該,還是讓我找到了上一篇的答案,于是沒有辦法寫下來與諸位分享。哥寫的真不是寂寞,是答案——有圖有真相的答案。

首先如果諸位不熟悉Helloj2ee的問題的,可以參見上一篇:Visual Studio 2010 RC關(guān)于WPF開發(fā)的X個不同之一——居然多了一個程序集引用

Helloj2ee總結(jié)出來的問題是 在VS2008里面 一個WPF程序至少需要四個程序集 system.dll,presentationframework.dll,windowsbase.dll和presentationcore.dll.

而Visual Studio 2010 RC里或者承蒙怕怕的韋恩卑鄙兄指點(diǎn),說的準(zhǔn)確些是WPF4。那么他需要的是五個程序集,除去剛才四個,還有就是System.xaml.dll。

現(xiàn)在Helloj2ee在這里告訴他的答案。如果在Visual Studio 2010 RC里編譯,會報(bào)一個什么錯誤呢?

error CS0012: The type 'System.Windows.Markup.IQueryAmbient' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

意思是已經(jīng)定義了一個IQueryAmbient接口,而這個接口在System.xaml程序集當(dāng)中。

如果您要去找IQueryAmbient接口,我打保票,您是尋訪整個工程都找不到的。如果您在過去的MSDN,我是指3.5SP1的MSDN去搜索IQueryAmbient接口,那也是找不到的。

好在.Net4.0里可以找到的,這里是該接口的官方文檔:http://msdn.microsoft.com/en-us/library/system.windows.markup.iqueryambient(VS.100).aspx

關(guān)鍵的修改之處在于FrameworkElement 實(shí)現(xiàn)了該接口。該接口是System.xaml.dll程序集當(dāng)中的,而Window又派生自FrameworkElement,因此需要該程序集的引用。

這個接口非常簡單只有一個稱之為IsAmbientPropertyAvailable的方法,傳遞進(jìn)去的參數(shù)是string,返回的是bool型。如下所示    

  1. // Summary:  
  2.     //     Queries for whether a specified property should be treated as ambient in  
  3.     //     the current scope.  
  4.     public interface IQueryAmbient  
  5.     {  
  6.         // Summary:  
  7.         //     Queries for whether a specified named property can be considered ambient  
  8.         //     in the current scope.  
  9.         //  
  10.         // Parameters:  
  11.         //   propertyName:  
  12.         //     The name of the property to check for ambience state.  
  13.         //  
  14.         // Returns:  
  15.         //     true if the requested property can be considered ambient; otherwise, false.  
  16.         bool IsAmbientPropertyAvailable(string propertyName);  
  17.     } 

這個接口的作用,我簡單看了一下還是為了提高效率的。具體也可以請各位高手指點(diǎn),我在這里拋磚先,你們盡管砸玉。

如果繼續(xù)Reflector的話,不難發(fā)現(xiàn)原有的System.windows.markup命名空間當(dāng)中的類和接口有相當(dāng)一部分從過去的Windowsbase.dll移植到了System.xaml.dll當(dāng)中。不妨看下面幾張圖。***張圖是3.0版本下面的WindowsBase.dll中的System.windows.markup當(dāng)中的類和接口,我只能說挺長,挺多。

接口

下一張就是4.0版本下面的windowsbase.dll當(dāng)中的System.windows.markup當(dāng)中的類和接口。

版本

可以看到相比上一張圖,類和接口少了不少。不是憑空消失了相當(dāng)一部分類和接口移到了System.xaml.dll程序集當(dāng)中了。比如IComponetConnector接口等。下圖就是System.xaml程序集當(dāng)中的關(guān)于System.windows.markup當(dāng)中的類和接口。

 類和接口

在這花好月圓夜,Helloj2ee寫下了事實(shí)的真相。當(dāng)然比較凌亂,概括一下就是三點(diǎn):

(1)WPF4當(dāng)中 FrameworkElement有所改動,它實(shí)現(xiàn)了IQueryAmbient接口,該接口正是傳說中的System.xaml程序集中的接口,因此需要引用該程序集,繞不開,躲不過。

(2)實(shí)現(xiàn)該接口的目的,由Helloj2ee初步判定是為了提高效率;

(3)原來在3.5SP1之前,WindowsBase.dll承擔(dān)了部分關(guān)于XAML的類和接口,在System.windows.markup明名空間當(dāng)中,好了4.0來了,他把這當(dāng)中的部分類和接口放在System.xaml這個程序集里。當(dāng)然具體還請各位自己查證。

原文標(biāo)題“VS2010RC關(guān)于WPF開發(fā)的X個不同之一——居然多了一個程序集引用”姊妹篇——有圖有真相

鏈接:http://www.cnblogs.com/helloj2ee/archive/2010/02/28/1675288.html

【編輯推薦】

  1. 一線程序員的Visual Studio 2010 RC初體驗(yàn)
  2. Visual Studio 2010敏捷之道
  3. Visual Studio 2010開發(fā)絢麗Win 7應(yīng)用程序
  4. 詳解Visual Studio 2010敏捷測試驅(qū)動開發(fā)
  5. Visual Studio 2010升級Web開發(fā)功能

責(zé)任編輯:彭凡 來源: 博客園
相關(guān)推薦

2010-03-01 09:16:22

Visual Stud

2010-03-16 14:32:16

Visual Stud

2009-03-05 08:47:33

WPFUIVisual Stud

2010-03-04 10:28:48

Visual Stud

2012-05-11 15:51:11

VisualStudiWindows8

2011-02-13 17:10:28

Visual Stud

2010-02-22 14:00:29

Visual Stud

2009-12-02 09:43:38

Visual Stud

2009-11-11 13:24:51

Visual Stud

2009-11-10 13:43:37

Visual Stud

2009-11-04 09:16:00

Visual Stud

2009-12-15 09:36:32

Visual Stud

2010-07-20 08:43:00

Visual Stud

2010-02-24 14:16:56

Visual Stud

2010-03-05 13:48:50

Visual Stud

2010-06-01 13:32:15

Visual Stud

2009-11-11 09:48:06

Visual Stud

2010-02-22 16:43:33

Visual Stud

2013-09-03 17:59:00

Visual StudVisual Stud微軟

2009-12-01 10:49:44

Visual Stud
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號