c# - The name 'InitializeComponent' does not exist in the current context. Cannot get any help on net searches -
hi getting error of initializecomponent
in app.xaml.cs
page have checked net , no solution works. please help.
c# file:
using system; using system.collections.generic; using system.linq; using system.net; using system.windows; using system.windows.controls; using system.windows.documents; using system.windows.input; using system.windows.media; using system.windows.media.animation; using system.windows.navigation; using system.windows.shapes; using microsoft.phone.controls; using microsoft.phone.shell; using newtonsoft.json; namespace miser_sapp { public partial class app : application { /// <summary> /// provides easy access root frame of phone application. /// </summary> /// <returns>the root frame of phone application.</returns> public phoneapplicationframe rootframe { get; private set; } /// <summary> /// constructor application object. /// </summary> public app() { // global handler uncaught exceptions. unhandledexception += application_unhandledexception; // standard silverlight initialization initializecomponent(); // phone-specific initialization initializephoneapplication(); // show graphics profiling information while debugging. if (system.diagnostics.debugger.isattached) { // display current frame rate counters. application.current.host.settings.enableframeratecounter = true; // show areas of app being redrawn in each frame. //application.current.host.settings.enableredrawregions = true; // enable non-production analysis visualization mode, // shows areas of page handed off gpu colored overlay. //application.current.host.settings.enablecachevisualization = true; // disable application idle detection setting useridledetectionmode property of // application's phoneapplicationservice object disabled. // caution:- use under debug mode only. application disables user idle detection continue run // , consume battery power when user not using phone. phoneapplicationservice.current.useridledetectionmode = idledetectionmode.disabled; } } // code execute when application launching (eg, start) // code not execute when application reactivated private void application_launching(object sender, launchingeventargs e) { } // code execute when application activated (brought foreground) // code not execute when application first launched private void application_activated(object sender, activatedeventargs e) { } // code execute when application deactivated (sent background) // code not execute when application closing private void application_deactivated(object sender, deactivatedeventargs e) { } // code execute when application closing (eg, user hit back) // code not execute when application deactivated private void application_closing(object sender, closingeventargs e) { } // code execute if navigation fails private void rootframe_navigationfailed(object sender, navigationfailedeventargs e) { if (system.diagnostics.debugger.isattached) { // navigation has failed; break debugger system.diagnostics.debugger.break(); } } // code execute on unhandled exceptions private void application_unhandledexception(object sender, applicationunhandledexceptioneventargs e) { if (system.diagnostics.debugger.isattached) { // unhandled exception has occurred; break debugger system.diagnostics.debugger.break(); } } #region phone application initialization // avoid double-initialization private bool phoneapplicationinitialized = false; // not add additional code method private void initializephoneapplication() { if (phoneapplicationinitialized) return; // create frame don't set rootvisual yet; allows splash // screen remain active until application ready render. rootframe = new phoneapplicationframe(); rootframe.navigated += completeinitializephoneapplication; // handle navigation failures rootframe.navigationfailed += rootframe_navigationfailed; // ensure don't initialize again phoneapplicationinitialized = true; } // not add additional code method private void completeinitializephoneapplication(object sender, navigationeventargs e) { // set root visual allow application render if (rootvisual != rootframe) rootvisual = rootframe; // remove handler since no longer needed rootframe.navigated -= completeinitializephoneapplication; } #endregion } }
xaml file:
<application x:class="miser_sapp.app" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phone="clr-namespace:microsoft.phone.controls;assembly=microsoft.phone" xmlns:shell="clr-namespace:microsoft.phone.shell;assembly=microsoft.phone"> <!--application resources--> <application.resources> </application.resources> <application.applicationlifetimeobjects> <!--required object handles lifetime events application--> <shell:phoneapplicationservice launching="application_launching" closing="application_closing" activated="application_activated" deactivated="application_deactivated"/> </application.applicationlifetimeobjects> </application>
i have uploaded app.xaml
contents. have not made changes in it.
there 2 potential causes of this.
the common x:class doesn't match mainpage.xaml namespace. make sure x:class in mainpage.xaml has correct namespace.
the second common cause of problem "build action" not set "page" mainpage.xaml!
Comments
Post a Comment