<?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>Programming with .NET - General</title><link>http://forums.silverlight.net/forums/17.aspx</link><description>General discussions around authoring Silverlight .NET applications.</description><dc:language>en</dc:language><generator>CommunityServer 2007 (Build: 20416.853)</generator><item><title>Weird problem with designer files and custom user controls</title><link>http://forums.silverlight.net/forums/thread/239180.aspx</link><pubDate>Mon, 29 Jun 2009 13:52:52 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:239180</guid><dc:creator>piratepops</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/239180.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=17&amp;PostID=239180</wfw:commentRss><description>&lt;p&gt;This really isn&amp;#39;t so much a PROBLEM as an irritation - was wondering if anyone had a fix for it other than just putting up with it.&amp;nbsp; Here is the situation:&lt;/p&gt;&lt;p&gt;&amp;nbsp;I&amp;#39;m working on a pretty large Silverlight LOB application.&amp;nbsp; I created a component as a XAML with its own code-behind, let&amp;#39;s call it MyControl.xaml.&amp;nbsp; This was added to the project, which we&amp;#39;ll call MyProject.&amp;nbsp; Also in MyProject is my main page, which we&amp;#39;ll call MainPage.xaml.&amp;nbsp; I add MyControl to MainPage by doing the following:&lt;/p&gt;&lt;p&gt;1)&amp;nbsp; I add a reference to it at the top of the xaml with:&lt;/p&gt;&lt;p&gt;&amp;lt;UserControl x:Class=&amp;quot;MyProject.MainPage&amp;quot;&lt;br /&gt;&amp;nbsp; &amp;nbsp; xmlns:data=&amp;quot;clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data&amp;quot;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:controls=&amp;quot;clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls&amp;quot; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:x=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:local=&amp;quot;clr-namespace:MyProject&amp;quot; &amp;gt; &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;2)&amp;nbsp; Futher down in the code of MainPage.xaml, I use the control with:&lt;/p&gt;&lt;p&gt;&amp;lt;local:MyControl x:name=&amp;quot;InstanceOfMyControl&amp;quot;&amp;gt;&amp;lt;/local:MyControl&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;At first, it works like a charm.&amp;nbsp; But then I start getting error messages, which sometimes prevent compilation that say that MyControl is not part of MyProject.&amp;nbsp; The error is in the file MainPage.g.vb, and the lines of code look like this:&lt;/p&gt;&lt;p&gt;&amp;nbsp;Friend WithEvents InstanceOfMyControl As MyProject.MyControl&lt;/p&gt;&lt;p&gt;and&lt;/p&gt;&lt;p&gt;Me.InstanceOfMyControl = CType(Me.FindName(&amp;quot;InstanceOfMyControl&amp;quot;), MyProject.InstanceOfMyControl)&lt;/p&gt;&lt;p&gt;&amp;nbsp;Now - when I debug this, the recommended change is to change the lines of code to this:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;Friend WithEvents InstanceOfMyControl As MyControl&lt;/p&gt;&lt;p&gt;and&lt;/p&gt;&lt;p&gt;Me.InstanceOfMyControl = CType(Me.FindName(&amp;quot;InstanceOfMyControl&amp;quot;), InstanceOfMyControl)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;This removes the error, everything compiles and runs fine.&amp;nbsp; But then after a few minutes, I guess when the .g.vb file is &amp;#39;re-generated&amp;#39;, the code goes back to the way it was, and the errors come back.&amp;nbsp; Sometimes they go away when I compile without me having to fix, but other times the app won&amp;#39;t compile at all until I manually fix the .g.vb file.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Any suggestions?&lt;/p&gt;&lt;p&gt;Thanks in advance,&lt;/p&gt;&lt;p&gt;Pops &lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>