<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.silverlight.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Report a Silverlight Bug</title><link>http://forums.silverlight.net/forums/28.aspx</link><description>Found a bug in Silverlight? Use this forum to describe the bug and the code or steps to reproduce it.</description><dc:language>en</dc:language><generator>CommunityServer 2007 (Build: 20416.853)</generator><item><title>Re: Accessing resources by name sometimes returns null</title><link>http://forums.silverlight.net/forums/thread/238420.aspx</link><pubDate>Fri, 26 Jun 2009 18:09:46 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:238420</guid><dc:creator>SharpGIS</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/238420.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=28&amp;PostID=238420</wfw:commentRss><description>&lt;p&gt;Just a little update on this which is still causing me a huge headache. By now I&amp;#39;m pretty convinced this is a serious Silverlight bug.&lt;/p&gt;&lt;p&gt;I have the exact same source code running on two difference machines. Both are running Windows 7RC and IE8 using Visual Studio 2008SP1 and same regional settings. Only difference is really the hardware.&lt;/p&gt;&lt;p&gt;The first screen shot is from the PC where this works. Notice that the resource collection has 3 elements in it: &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;img src="http://silverlight.sharpgis.net/bugs/success_02.png" width="868" height="605" alt="" /&gt;&lt;/p&gt;&lt;p&gt;Here is the same screenshot on the PC where this fails. As far as I can tell, all the fields,public and non-public properties are all the same when drilling down deep. So far so good.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;img src="http://silverlight.sharpgis.net/bugs/fail_02.png" alt="" /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;Here I&amp;#39;m accessing a specific resource item on the PC where this works, and we get an object back as expected: &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;img src="http://silverlight.sharpgis.net/bugs/success_01.png" alt="" /&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Here is the same watch on the PC where it doesn&amp;#39;t work. For whatever reason, this returns null :&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;img src="http://silverlight.sharpgis.net/bugs/fail_01.png" alt="" /&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The class type I&amp;#39;m accessing is a simple DependencyObject with a couple of simple properties and a ControlTemplate property. Nothing fancy at all.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;This is a HUGE problem for us. On some PC&amp;#39;s this happens consistent, on others a page refresh will resolve the issue, and in some cases, just unloading and reloading the usercontrol will resolve it. It also seems to vary with the application that is running. Some apps will work fine, and others won&amp;#39;t. Even the machine that it works great on in this case, will sometimes fail in other cases.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;When stepping through the code, the object&amp;#39;s constructor is called, and no errors are thrown when stepping through all the code up to this point. Everything basically seems fine, and nothing indicates a problem.&amp;nbsp; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;Another thing worth noting is that this does not seem to happen if the resource is referenced somewhere in the XAML, but in this case it is only used in the code-behind.&lt;/p&gt;&lt;p&gt;I&amp;#39;m not looking for an ugly workaround here (I could just create the object in code and move on), but I&amp;#39;m looking for something that we could avoid doing, so all our developers will not have to use this workaround over and over again. &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Re: Accessing resources by name sometimes returns null</title><link>http://forums.silverlight.net/forums/thread/226419.aspx</link><pubDate>Fri, 29 May 2009 11:49:53 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:226419</guid><dc:creator>sharad.saxena</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/226419.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=28&amp;PostID=226419</wfw:commentRss><description>&lt;p&gt;I&amp;#39;m also experiencing exactly same problem. &lt;/p&gt;
&lt;p&gt;On my previous machine, the same code was running fine. When I moved the code to another machine, value of the&amp;nbsp;symbol becomes null. Which results No geomatry on map.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve tried lots of options but no success yet. I&amp;#39;m stucked and need help.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Accessing resources by name sometimes returns null</title><link>http://forums.silverlight.net/forums/thread/213112.aspx</link><pubDate>Tue, 28 Apr 2009 17:31:35 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:213112</guid><dc:creator>SharpGIS</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/213112.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=28&amp;PostID=213112</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Nope. As I wrote, this happens anytime during the entire lifecycle, even at MouseDown events looooong after the page has loaded.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Accessing resources by name sometimes returns null</title><link>http://forums.silverlight.net/forums/thread/213064.aspx</link><pubDate>Tue, 28 Apr 2009 16:04:05 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:213064</guid><dc:creator>morfing</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/213064.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=28&amp;PostID=213064</wfw:commentRss><description>Hi,


Silverlight is a client application and somethings depends from client machine speed.

I think you have to put your code in an event handler like: myObject.Loaded</description></item><item><title>Accessing resources by name sometimes returns null</title><link>http://forums.silverlight.net/forums/thread/208752.aspx</link><pubDate>Sun, 19 Apr 2009 21:06:07 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:208752</guid><dc:creator>SharpGIS</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/208752.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=28&amp;PostID=208752</wfw:commentRss><description>&lt;p&gt;I&amp;#39;ve been experiencing a weird and inconsistent issue with Silverlight, where accessing resources from code sometimes fails.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;I have a custom class inheriting from DependencyObject:&lt;/p&gt;
&lt;p&gt;public class Symbol : DependencyObject&amp;nbsp; { ... } &lt;br /&gt;&lt;/p&gt;
&lt;p&gt;I declare an instance of this symbol class in my resources like so:&lt;/p&gt;







&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;Grid&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;color:red;"&gt; x&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;color:blue;"&gt;:&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;color:red;"&gt;Name&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;color:blue;"&gt;=&amp;quot;LayoutRoot&amp;quot;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;Grid.Resources&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;local&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;color:blue;"&gt;:&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;Symbol&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;color:red;"&gt; x&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;color:blue;"&gt;:&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;color:red;"&gt;Name&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;color:blue;"&gt;=&amp;quot;mySymbol&amp;quot;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;color:red;"&gt; &lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;color:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;Grid.Resources&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;color:blue;"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;Grid&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;color:blue;"&gt; &amp;gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Sometimes when accessing the symbol by name from code like this:&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Symbol&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt; symbol1 = mySymbol; &lt;span style="color:green;"&gt;//Sometimes returns null&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
 the symbol will be null. However, if I access it by the resource name:
&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Symbol&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;
symbol2 = LayoutRoot.Resources[&lt;span&gt;&amp;quot;mySymbol&amp;quot;&lt;/span&gt;]
&lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span&gt;Symbol&lt;/span&gt;;
&lt;span style="color:green;"&gt;//Always works&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;...it works fine.&lt;/p&gt;
&lt;p&gt;However, this problem is not consistent. On some computers it works, on others it don&amp;#39;t (even with same OS/browser). Other times it fails the first time the usercontrol with this code in it loads, but works the next time it load, and it doesn&amp;#39;t matter what time of the control lifecycle I do this in (from constructor, though load handlers over to button click handlers), and other times a specific usercontrol always fails, but the same code works fine in other usercontrols. I&amp;#39;ve had a really hard time finding anything consistent with this bug.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Is this a known bug in Silverlight2?&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;As an interesting side note, WPF wouldn&amp;#39;t even allow you to access DependencyObjects in the resources by name (you use x:Key instead of x:Name and use the second approach above), so this might just be a design flaw in Silverlight, that shouldn&amp;#39;t have allowed you to do this in the first place, but if only the error was consistent, that would be ok (IMHO the compiler shouldn&amp;#39;t even allow you to access it from code by name but that&amp;#39;s what our users do, and intellisense throws them down that path). &lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>