vs2010下載入設計器異常問題(費了3天的時間終於解決)

在vs2010下新建silverlight application剛剛建好就出現設計器載入異常的問題。代碼都是有vs2010自動產生的,所以代碼應該沒問題。求解釋,這個困然了我很久了。

以下是vs2010給出的提示:System.NullReferenceException
未將對象引用設置到對象的實例。
  在 Microsoft.Windows.Design.Platform.SilverlightMetadataContext.SilverlightXamlExtensionImplementations.<GetXmlNamespaceCompatibilityMappings>d__8.MoveNext()
  在 MS.Internal.Design.Metadata.ReflectionProjectNode.BuildSubsumption()
  在 MS.Internal.Design.Metadata.ReflectionProjectNode.SubsumingNamespace(Identifier identifier)
  在 MS.Internal.Design.Markup.XmlElement.BuildScope(PrefixScope parentScope, IParseContext context)
  在 MS.Internal.Design.Markup.XmlElement.ConvertToXaml(XamlElement parent, PrefixScope parentScope, IParseContext context, IMarkupSourceProvider provider)
  在 MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.FullParse(Boolean convertToXamlWithErrors)
  在 MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.get_RootItem()
  在 Microsoft.Windows.Design.DocumentModel.Trees.ModifiableDocumentTree.get_ModifiableRootItem()
  在 Microsoft.Windows.Design.DocumentModel.MarkupDocumentManagerBase.get_LoadState()
  在 MS.Internal.Host.PersistenceSubsystem.Load()
  在 MS.Internal.Host.Designer.Load()
  在 MS.Internal.Designer.VSDesigner.Load()
  在 MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedView.Load()
  在 MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedDesignerFactory.Load(IsolatedView view)
  在 MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view)
  在 MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view)
  在 MS.Internal.Host.Isolation.IsolatedDesigner.Load()
  在 MS.Internal.Designer.DesignerPane.LoadDesignerView()
一下是vs2010產生的代碼:<UserControl x:Class="FirstSliverlight.MainPage"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="d"
  d:DesignHeight="300" d:DesignWidth="400">

  <Grid x:Name="LayoutRoot" Background="White">

  </Grid>
</UserControl>
以及錯誤列表中的提示:錯誤 1 未將對象引用設置到對象的實例。 D:/My workspace/SilverLight/FirstSliverlight/FirstSliverlight/MainPage.xaml 1 1 FirstSliverlight
錯誤 2 在“D:/My workspace/SilverLight/FirstSliverlight/FirstSliverlight/MainPage.xaml”上引發了 System.NullReferenceException: 未將對象引用設置到對象的實例。 D:/My workspace/SilverLight/FirstSliverlight/FirstSliverlight/MainPage.xaml 1 1 FirstSliverlight

 

解決方案:

先說我的解決流程:

第一種解決方案(不行):
卸載vs2010,然後重裝。(當初以爲2010出了問題)

第二種方案(也不行):打開silverlight tookit命令,按以下操作:1.打開 visual studio 命令提示 輸入一下命令

2.devenv /resetskippkgs 這條命令會啓動visual stuio 關閉visual studio然後輸入下面的命令


3.devenv /setup

第三種方案(OK):先把所有與siverlight有關的silverlight,silverlightsdk,silverlight_too ,silverlight toolkit,全部卸掉,然後重裝,然後啓動2010,打開原來的silverlight的項目OK,新疆項目也OK

總結:通過以上解決方法,可以看出silverlight的開發環境要求比較嚴格,並且其開發環境不是集成在一個安裝包,而是分散的,所以安裝時必須注意版本和順序,否則就可能造成意想不到的問題。所謂版本要求個人和網上理解爲要麼全部爲中文版,全部爲英文版,並且版本號儘量一致,以前我安裝的時候碰到了一個版本不一致問題就是,我安裝了vs2010英文旗艦版,然後安裝中文版silverlight_tools,就出現問題.

所以我總結了一下安裝順序應該爲1、vs2010。2、silverlight4。3、silverlight4_tool.(其中包含)4、silverlight toolkit

最後祝各位碰到此問題的朋友能擺脫此問題的困擾!!!!!!!!!!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章