XAML程序集引用问题

3

我有一个问题,我的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。


你为什么要在临时目录中引用程序集? - Kent Boogaart
我已经尝试了两种方式,结果相同。我将它们设置为瞬态,这样当有人从源代码控制中拉出时,它仍然可以工作。这可能是无意义的,因为我已经卸载了项目并创建了另一个项目,以查看新项目上的配置。重新加载我的项目后,问题似乎已经消失了。 - PhilBrown
1
但这不起作用,因为您不应该检查您的Bin目录。通常您会有一个已检入的Lib(或类似)目录,并且您会引用其中的程序集。我知道这不能解决您最初的问题,但只是想问一下。 - Kent Boogaart
很好的观点。这是一个非常年轻的项目,我们正在解决其中的问题。我描述的方法之后,我的问题已经消失了。谁知道为什么VS2010会表现出这种行为。 - PhilBrown
1个回答

2

我上面的评论关于创建一个新项目并重新加载原始项目似乎运行良好。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接