Programming with .NET - Generalhttp://forums.silverlight.net//17.aspx/1?Programming+with+NET+GeneralGeneral discussions around authoring Silverlight .NET applications.Mon, 01 Jan 0001 00:00:00 -0500174557http://forums.silverlight.net//p/1883/4557.aspx/1?FIX+ControlBase+Problem+in+Silverlight+Samples+Controls+Resource+Search+Scoped+only+to+Sample+AssemblyFIX - ControlBase Problem in Silverlight.Samples.Controls - Resource Search Scoped only to Sample Assembly <p>FYI. I ran into this problem tonight, and thought I'd post the solution here.</p> <p>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&nbsp;I reference it from my main project.</p> <p>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.</p> <p>The SDK ControlBase constructor tries to be&nbsp;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&nbsp;calls this code:</p> <font color="#0000ff" size="2"><font color="#2b91af" size="2">&nbsp;&nbsp;&nbsp;&nbsp; Assembly</font><font color="#000000" size="2"> assembly = </font><font color="#0000ff" size="2">typeof</font><font color="#000000" size="2">(</font><font color="#2b91af" size="2">ControlBase</font><font size="2"><font color="#000000">).Assembly;</font></font><font size="2"> <p></font>&nbsp;&nbsp;&nbsp;&nbsp; string</font><font size="2">[] names = assembly.GetManifestResourceNames();</p> <p></font>which&nbsp;brings back only&nbsp;xaml files that are part of the SL&nbsp;Samples assembly.Changing that line to this fixes the problem:</p> <font color="#0000ff" size="2"><font size="2"></font><font color="#2b91af" size="2">&nbsp;&nbsp;&nbsp;&nbsp; Assembly</font><font size="2"> assembly = </font><font color="#0000ff" size="2">this</font><font size="2"><font color="#000000">.GetType().Assembly</font>;</font></font><font size="2"> <p></font>&nbsp;&nbsp;&nbsp;&nbsp; string<font size="2">[] names = assembly.GetManifestResourceNames();</font></p> <p>Pete</p> <p>&nbsp;</p> <p>&nbsp;</p> 2007-06-08T04:04:50-04:004667http://forums.silverlight.net//p/1883/4667.aspx/1?Re+FIX+ControlBase+Problem+in+Silverlight+Samples+Controls+Resource+Search+Scoped+only+to+Sample+AssemblyRe: FIX - ControlBase Problem in Silverlight.Samples.Controls - Resource Search Scoped only to Sample Assembly <p>Thank you for documenting this workaround. It will be useful for developers extending the Silverlight 1.1 Alpha controls. </p> <p>When we designed the UI controls, we made an implicit assumption that people would add their derivative controls to the same project and by extension they will be built into the same assembly. Unfortunately we didn't document this assumption in the code where the assembly check happens (which you point out).</p> 2007-06-09T13:59:32-04:004670http://forums.silverlight.net//p/1883/4670.aspx/1?Re+Re+FIX+ControlBase+Problem+in+Silverlight+Samples+Controls+Resource+Search+Scoped+only+to+Sample+AssemblyRe: Re: FIX - ControlBase Problem in Silverlight.Samples.Controls - Resource Search Scoped only to Sample Assembly <p>Thanks Ashish</p> <p>It's an add-on pack to an alpha product, so no worries :)</p> <p>Pete</p> 2007-06-09T14:41:54-04:00