我有一个问题,我在我的 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>
其中一些具有已复制到调试目录的程序集的本地路径。它们肯定存在,还有同名的 .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 设计器和智能感知。
最佳答案
我上面关于创建新项目和重新加载原始项目的评论似乎工作正常。
关于visual-studio - xaml程序集引用问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3559464/