Budda
Budda

Reputation: 18343

Silverlight 4: How to reference class from another assembly

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 unclear why specified namespace is unknown (those assembly is referenced by the current one).

Please advise.

Any thoughts are welcome.

Upvotes: 0

Views: 2440

Answers (1)

Adam Sills
Adam Sills

Reputation: 17062

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

Upvotes: 2

Related Questions