我有一个问题,我的Silverlight应用程序中大部分引用的程序集似乎在xaml中找不到,尽管我已经使用“添加引用”对话框将它们添加到项目中,可以看到它们存在于指定的位置,并且可以使用对象浏览器浏览它们。 我正在使用VS 2010和SL4以及最新的SL工具包。
这里是fsproj文件中的参考...
<ItemGroup>
<Reference Include="FSharp.PowerPack">
<HintPath>C:\Program Files\FSharpPowerPack-2.0.0.0\Silverlight\v3.0\FSharp.PowerPack.dll</HintPath>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="FSharp.Core">
<HintPath>$(ProgramFiles)\Microsoft F#\Silverlight\Libraries\Client\$(SilverlightVersion)\FSharp.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Windows" />
<Reference Include="System.Windows.Browser" />
<Reference Include="System.Windows.Controls">
<HintPath>bin\Debug\System.Windows.Controls.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Controls.Data">
<HintPath>bin\Debug\System.Windows.Controls.Data.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Controls.Data.Input" />
<Reference Include="System.Windows.Controls.DataVisualization.Toolkit">
<HintPath>bin\Debug\System.Windows.Controls.DataVisualization.Toolkit.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Controls.Input">
<HintPath>c:\Program Files\Microsoft SDKs\Silverlight\v4.0\Libraries\Client\System.Windows.Controls.Input.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Controls.Layout.Toolkit">
<HintPath>bin\Debug\System.Windows.Controls.Layout.Toolkit.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Controls.Navigation">
<HintPath>c:\Program Files\Microsoft SDKs\Silverlight\v4.0\Libraries\Client\System.Windows.Controls.Navigation.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Controls.Toolkit">
<HintPath>bin\Debug\System.Windows.Controls.Toolkit.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Data">
<HintPath>bin\Debug\System.Windows.Data.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
</ItemGroup>
其中一些引用本地路径到已复制到Debug目录的程序集。它们肯定在那里,与同名的.xml文件(例如System.Windows.Controls.Navigation.dll和System.Windows.Controls.Navigation.xml)一起。无论引用它们的位置在哪里,我都会遇到相同的问题。
以下是它们在xaml中的引用方式...
<nav:Page x:Class="Module1.MyIdeas" x:Name="MyIdeas"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
xmlns:nav="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
xmlns:winControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:y="clr-namespace:Module1" NavigationCacheMode="Enabled" >
<some content.../>
</nav:Page>
所有以下的程序集都出现了错误:"错误1:找不到程序集 'System.Windows.Controls.X'。请确认您没有漏掉任何程序集引用。同时,请确认您的项目和所有参考的程序集已经被构建。"
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
xmlns:nav="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
项目可以成功构建和运行,但这种行为似乎会破坏XAML设计器和Intellisense。