locked
Consistent blocking error from generated App.g.cs RRS feed

  • Question

  •  

    Hello, I've been playing with WPF and unfortunately have run into a problem that's blocking my development.  I created a new WPF application using Visual C# Express 2008 and successfully created a window with controls based on XAML.  I experimented with different data binding techniques and was having a lot of fun until I tried adding another window and DataSet to my project.  I'm not sure if these new items are related, but the issue I'm seeing is with the apparently autogenerated App.g.cs file, specifically Visual Studio seems to be generating a file with a syntax error that blocks compilation. 

     

    The App.g.cs file looks like this:

     

    #pragma checksum "..\..\App.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "5D98E682C9F019A4BA7D2194E63D6754"

    //------------------------------------------------------------------------------

    // <auto-generated>

    // This code was generated by a tool.

    // Runtime Version:2.0.50727.1433

    //

    // Changes to this file may cause incorrect behavior and will be lost if

    // the code is regenerated.

    // </auto-generated>

    //------------------------------------------------------------------------------

    using MS.Internal.Xaml.Builtins;

    using System;

    using System.Windows;

    using System.Windows.Automation;

    using System.Windows.Controls;

    using System.Windows.Controls.Primitives;

    using System.Windows.Data;

    using System.Windows.Documents;

    using System.Windows.Ink;

    using System.Windows.Input;

    using System.Windows.Markup;

    using System.Windows.Media;

    using System.Windows.Media.Animation;

    using System.Windows.Media.Effects;

    using System.Windows.Media.Imaging;

    using System.Windows.Media.Media3D;

    using System.Windows.Media.TextFormatting;

    using System.Windows.Navigation;

    using System.Windows.Shapes;

     

    namespace Recipes {

    /// <summary>

    /// App

    /// </summary>

    public partial class App : System.Windows.Application {

    /// <summary>

    /// InitializeComponent

    /// </summary>

    [System.Diagnostics.DebuggerNonUserCodeAttribute()]

    public void InitializeComponent() {

    #line 4 "..\..\App.xaml"

    this.StartupUri = new System.Uri("Window1.xaml", System.UriKind.Relative);

    #line default

    #line hidden

    }

    /// <summary>

    /// Application Entry Point.

    /// </summary>

    [System.STAThreadAttribute()]

    [System.Diagnostics.DebuggerNonUserCodeAttribute()]

    public static void Main() {

    Recipes.App app = new Recipes.App();

    app.InitializeComponent();

    app.Run();

    }

    }

    }

     

    The error is in the line Recipes.App app = new Recipes.App();, I get this compile error:

     

    Error 1 The type name 'App' does not exist in the type 'Recipes.Recipes' 

     

    It looks like Visual Studio is adding a reference to the Recipes namespace when accessing the App class, however because App is defined in the Recipes namespace this isn't necessary.  If I modify the line so it reads:

     

    App app = new App();

     

    The application compiles however when I hit F5 to run in debug mode Visual Studio seems to regenerate this file incorrectly and compilation again fails, completely blocking my application from running. Sad  Couple questions:

     

    1. What is this .g.cs file and why isn't it in my project?  I can only see the file when there's a compilation error, it doesn't appear in my solution.

    2. How do I fix the problem?  I don't know what I did to cause the problem, the project was compiling and working great until I added a new window (new .xaml file) and a DataSet, now I see this problem.

    3. Is there any way I can work around this auto generated file?  It looks like this is a simple class that holds the main entry point for my app, is there any reason I can't create this myself and tell Visual Studio to stop (incorrectly) generating this file?

     

    Thanks for any help you can provide, let me know if there is a better audience for this question.

    Friday, December 21, 2007 4:57 AM

All replies

  • Well this is really weird, if I compile my application with F6 Build and run the release version with Ctrl-F5 it works perfectly, but if I hit F5 to run in debug mode I get this error.  Anyone know what's going on and why I would get a compile error only when running in debug mode?

     

    Side question, is there a good explanation of what Visual Studio is doing under the covers with all these autogenerated files and dependencies on release modes?  This is very frustrating that my applicaiton just stops working in debug mode, luckily this is just a toy project.

     

    Friday, December 21, 2007 5:08 AM
  • Hi tdicola,

     

    sorry that no one has answered your post so far. You can try asking in the "Visual Studio WPF Designer" forum: http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=169&SiteID=1

     

    Also, if you think this is a bug (and to me it looks like a bug), you could submit a bug report over here: https://connect.microsoft.com/visualstudio/feedback

     

    Thanks!

    Kirill

    Friday, January 11, 2008 3:56 AM
  • Hello tdicola,

    See if you have a class defined with the same name of the project. I had the same problem, I delete the class and create with another name and all work again.

    Viele Gluck!
    Friday, March 13, 2009 4:51 PM