Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

  • Psychlist1972

    Psychlist1972

    Contributor

    6802 Points

    1079 Posts

    Microsoft

    Moderator

    FIX - ControlBase Problem in Silverlight.Samples.Controls - Resource Search Scoped only to Sample...

    Jun 08, 2007 04:04 AM | LINK

    FYI. I ran into this problem tonight, and thought I'd post the solution here.

    I am using sample controls in the SDK. In my solution, I have kept the 1.1 SDK example in its own project, as it is shipped, and I reference it from my main project.

    In the Silverlight SDK Controls examples, there is a class named ControlBase. In my main project, I have a button-type control that inherits from SDK ButtonBase which inherits from ControlBase.

    The SDK ControlBase constructor tries to be clever about picking up the name of the xaml file that contains the markup for the derived control. Unfortunately, it is unable to check outside of its own assembly because it calls this code:

         Assembly assembly = typeof(ControlBase).Assembly;

         string[] names = assembly.GetManifestResourceNames();

    which brings back only xaml files that are part of the SL Samples assembly.Changing that line to this fixes the problem:

         Assembly assembly = this.GetType().Assembly;

         string[] names = assembly.GetManifestResourceNames();

    Pete

     

     

    Resources SDK 1.1 Bug

    Developer Community Program Manager - XAML, WPF, Silverlight, .NETMF/Gadgeteer
    10rem.net - Pete Brown's site and blog | twitter: @pete_brown
    I work for the Developer Guidance group in Microsoft. Opinions are my own.