Search code examples
visual-studio-2008silverlightxamlexpression-blend

Silverlight color resources using A="" R="" G="" B="" cause exception in app


When defining a color resource in a Silverlight app using the syntax A="" R="" G="" B="" (any order of parameters) an exception is caused, even though the application will compile fine and display properly in Blend.

Example:

<UserControl.Resources>
   <Color x:Key="BlackBG" A="255" R="35" G="35" B="35"/>
</UserControl.Resources>

The error reported if using an HTML Object tag to display the Silverlight control will be

Unhandled Error in Silverlight 2 Application Code: 2103
Category: InitializeError
Message: Invalid or malformed application: Check manifest


Solution

  • Instead of using the A="" R="" G="" B="" syntax, e.g.

    <Color x:Key="BlackBG" A="255" R="35" G="35" B="35"/>
    

    Use the alternate syntax

    <Color x:Key="BlackBG">#FF252525</Color>