开发者

Silverlight 4: How to reference class from another assembly

开发者 https://www.devze.com 2023-01-15 19:32 出处:网络
In XAML-file of the SquadView page (VfmElitaSilverlightClientView.Pages.SquadView) I am using custom value converter. XAML-file is in \"VfmElitaSilverlightClientView\" namespace. Separate folder was c

In XAML-file of the SquadView page (VfmElitaSilverlightClientView.Pages.SquadView) I am using custom value converter. XAML-file is in "VfmElitaSilverlightClientView" namespace. Separate folder was created for converter and it is in "VfmElitaSilverlightClientView.Converter" namespace (in the same assembly). To use converter following code is used in XAML:

xmlns:Converter="clr-namespace:VfmElitaSilverlightClientView.Converter"
...
<NavigationControls:Page.Resources>
    <Converter:BooleanToVisibilityConverter x:Key="resourceBooleanToVisibilityConverter" />
</NavigationControls:Page.Resources>

All works fine. Here I want to move converter class into a custom separate assembly "SilverlightCommonView" and class himself will be in "SilverlightCommonView.Converter" namespace. The XAML code is changed to the following:

xmlns:Converter="clr-namespace:SilverlightCommonView.Converter;assembly=SilverlightCommonView" 
...
<NavigationControls:Page.Resources>
    <Converter:BooleanToVisibilityConverter x:Key="resourceBooleanToVisibilityConverter" />
</NavigationControls:Page.Resources>

In this case when application throws following exception:

An unhandled exception ('Unhandled Error in Silverlight Application... Code: 4004 Category: ManagedRuntimeError Message: Microsoft.Practices.Unity.ResolutionFailedException: Resolution of dependency failed, type="VfmElitaSilverlightClientView.Pages.SquadView", name="(none)". Exception occurred while: Calling constructor VfmElitaSilverlightClientView.Pages.SquadView(). Exception is: XamlParseException - The type 'BooleanToVisibilityConverter' was not found because 'cl...:SilverlightCommonView.Converter;assembly=SilverlightCommonView' is an unknown namespace.

It's uncle开发者_Python百科ar why specified namespace is unknown (those assembly is referenced by the current one).

Please advise.

Any thoughts are welcome.


I'd bet you do not have an assembly reference to your shared/common project from your application project.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号