The name 'InitializeComponent' does not exist....<p>I'm trying to create a UserControl in a Class Library and it all works just fine. I can see everything in designer, but when I'm trying to build my solution I get the following error.</p> <p>The name 'InitializeComponent' does not exist in the current context</p> <p>And that's it, as it says I don't have that method in my .cs codebehind file. But the thing is when I create a UserControl in a WinFX Windows Application I can build it just fine, so i must be missing something. I tried removing the method call and that let me build it, but when creating a new instance and adding it to my Grid nothing happend. </p> <p>Any idea what I'm doing wrong. </p> <p>I am somewhat new to the .NET platform ( great idea jumping on the .NET 3.0 wagon then huh <img src="images/emoticons/smile_omg.gif"> ) But I would really like some help on this issue, because I do not have the slightest idea where to go from here.</p>© 2009 Microsoft Corporation. All rights reserved.Thu, 12 Nov 2009 09:43:53 Z2f755d30-bd8c-4f9b-b36a-9cb56bea15cdhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/2f755d30-bd8c-4f9b-b36a-9cb56bea15cd#2f755d30-bd8c-4f9b-b36a-9cb56bea15cdhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/2f755d30-bd8c-4f9b-b36a-9cb56bea15cd#2f755d30-bd8c-4f9b-b36a-9cb56bea15cdChristian Sparrehttp://social.msdn.microsoft.com/Profile/en-US/?user=Christian%20SparreThe name 'InitializeComponent' does not exist....<p>I'm trying to create a UserControl in a Class Library and it all works just fine. I can see everything in designer, but when I'm trying to build my solution I get the following error.</p> <p>The name 'InitializeComponent' does not exist in the current context</p> <p>And that's it, as it says I don't have that method in my .cs codebehind file. But the thing is when I create a UserControl in a WinFX Windows Application I can build it just fine, so i must be missing something. I tried removing the method call and that let me build it, but when creating a new instance and adding it to my Grid nothing happend. </p> <p>Any idea what I'm doing wrong. </p> <p>I am somewhat new to the .NET platform ( great idea jumping on the .NET 3.0 wagon then huh <img src="images/emoticons/smile_omg.gif"> ) But I would really like some help on this issue, because I do not have the slightest idea where to go from here.</p>Tue, 12 Sep 2006 20:06:46 Z2006-09-12T23:48:21Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/2f755d30-bd8c-4f9b-b36a-9cb56bea15cd#5b1075e5-670a-411d-85b8-be257439bf5fhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/2f755d30-bd8c-4f9b-b36a-9cb56bea15cd#5b1075e5-670a-411d-85b8-be257439bf5fRob Relyeahttp://social.msdn.microsoft.com/Profile/en-US/?user=Rob%20RelyeaThe name 'InitializeComponent' does not exist....<p>The initializeComponent routine is created in the .g.cs file that is created during build.  (see obj\debug\...)</p> <p>Make sure your XAML file has a build action of &quot;Page&quot; to create that file.</p> <p> </p> <p>Also, make sure that the partial classes in .xaml.cs and .g.cs match.</p> <p>Hope that helps.</p> <p>Thanks, Rob Relyea<br>WPF Team<br><a title="http://rrelyea.spaces.live.com" href="http://rrelyea.spaces.live.com">http://rrelyea.spaces.live.com</a></p> <p> </p>Tue, 12 Sep 2006 20:26:25 Z2006-09-12T20:26:25Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/2f755d30-bd8c-4f9b-b36a-9cb56bea15cd#87128f70-ed10-498e-bae0-2cdef671aa08http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/2f755d30-bd8c-4f9b-b36a-9cb56bea15cd#87128f70-ed10-498e-bae0-2cdef671aa08Christian Sparrehttp://social.msdn.microsoft.com/Profile/en-US/?user=Christian%20SparreThe name 'InitializeComponent' does not exist....<P>Thank's Rob, but it didn't seem to help, everything was set up as you said.</P> <P>I cruised a bit more around and stumbled over this</P> <P><a target="_blank" title="http://blogs.msdn.com/mhendersblog/archive/2005/10/03/476536.aspx" href="http://blogs.msdn.com/mhendersblog/archive/2005/10/03/476536.aspx">http://blogs.msdn.com/mhendersblog/archive/2005/10/03/476536.aspx</a>&nbsp;( something about hosting WPF in WinForms, quite clever actually <IMG src="http://forums.microsoft.com/MSDN/images/emoticons/smile_teeth.gif">&nbsp;)</P> <P>I't seems that when creating a DLL project (as with WinForms) Visual Studio can't handle "WPF/WinFX file types", so all&nbsp;I had to do was add &lt;Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" /&gt; in my .csproj file.</P> <P>Now it works like a charm <IMG src="images/emoticons/smile_tongue.gif"></P> <P>PS. thank's for keeping us up to date on the RC1 and Sept. CTP releases</P>Tue, 12 Sep 2006 21:41:35 Z2008-01-10T21:49:20Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/2f755d30-bd8c-4f9b-b36a-9cb56bea15cd#05819718-f6a3-48f0-a4a3-fa4d46fad206http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/2f755d30-bd8c-4f9b-b36a-9cb56bea15cd#05819718-f6a3-48f0-a4a3-fa4d46fad206Rob Relyeahttp://social.msdn.microsoft.com/Profile/en-US/?user=Rob%20RelyeaThe name 'InitializeComponent' does not exist....<p>Ah, yes, I should have noticed you said &quot;Class Library&quot;.</p> <p>If you use the Wpf Custom Control Project, that will have been done for you.</p> <p>Thanks, Rob</p>Tue, 12 Sep 2006 23:48:12 Z2006-09-12T23:48:12Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/2f755d30-bd8c-4f9b-b36a-9cb56bea15cd#6c4823f4-1b85-4757-838d-e225aef33908http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/2f755d30-bd8c-4f9b-b36a-9cb56bea15cd#6c4823f4-1b85-4757-838d-e225aef33908Mark K. Millerhttp://social.msdn.microsoft.com/Profile/en-US/?user=Mark%20K.%20MillerThe name 'InitializeComponent' does not exist....<P>Rob, we need better discoverability on this. The error message needs to do a better job at guiding us to the solution.</P> <P>Update: I'm not seeing a "Wpf Custom Control Project" project option inside VS 2005. In the Add New Project dialog I only see:</P> <P>Windows Application<BR>Class Library<BR>Windows Control Library<BR>Windows Application (WPF)&nbsp;</P> <P>And several other objects that are obviously not relevant.</P>Sat, 17 Mar 2007 20:15:55 Z2007-03-17T20:15:55Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/2f755d30-bd8c-4f9b-b36a-9cb56bea15cd#65ecfe70-c47b-4281-915e-abfbc1b1fb54http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/2f755d30-bd8c-4f9b-b36a-9cb56bea15cd#65ecfe70-c47b-4281-915e-abfbc1b1fb54Rob Relyeahttp://social.msdn.microsoft.com/Profile/en-US/?user=Rob%20RelyeaThe name 'InitializeComponent' does not exist....<p>Hey Mark-</p> <p>With the VS 2005 extensions, you are looking for &quot;Custom Control Library (WPF)&quot; which is not listed in the main nodes (C# or VB), but can only be found under the &quot;Net Framework 3.0&quot; node of Project Types.</p> <p>In VS &quot;Orcas&quot; March 2007 CTP, VB &amp; C# are a bit different:</p> <ul> <li>VB:  Under the &quot;Windows&quot; node of VB projects, there is &quot;WPF Custom Control Library&quot; and &quot;WPF User Control Library&quot;.</li> <li>C#: Under the top level node and the &quot;Windows&quot; node, there is &quot;WPF User Control Library&quot; available.</li></ul> <p>(my guess is that the orcas one may change a little bit...)</p> <p><font face=Verdana>Hope that helps.</font></p> <p><font face=Verdana>-Rob</font></p>Sun, 18 Mar 2007 14:02:00 Z2007-03-18T14:02:00Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/2f755d30-bd8c-4f9b-b36a-9cb56bea15cd#b8288dc9-bc3a-4a3c-ab43-4f5a439421a5http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/2f755d30-bd8c-4f9b-b36a-9cb56bea15cd#b8288dc9-bc3a-4a3c-ab43-4f5a439421a5Mr. Bunglehttp://social.msdn.microsoft.com/Profile/en-US/?user=Mr.%20BungleThe name 'InitializeComponent' does not exist....Just came across this compile error when I created a new WPF user control in VS 2008.  I had used Visual Studio's 'Refactor' to change the class name, but it failed to rename the class name in the XAML (only in code-behind).  Changing the class name there to match fixed the problem.  <br>Mon, 05 Jan 2009 11:20:43 Z2009-01-05T11:21:34Z