Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

David Rogers

David Rogers dwrogers

Niner since 2009

Developer. Old school. Love new stuff.
  • Navigation Between MainPage and ViewEdit Pages - Day 4 - Part 10

    "Well, I'm looking at this and I'm seeing here that I clearly have pulled this out of somewhere..." Smiley

    ROFL!

  • Tombstoning and Task Switching - Day 3 - Part 8

    The sequence of Load, Activate, Deactivate, and Close calls was not obvious at first. And the fact that the debugger keeps dropping out makes it tough to follow. A useful extension to this module would be to record each of these events (WHEN it occurred) in the string we are saving.

    These changes would go in App.xaml.cs:

            private void Application_Launching(object sender, LaunchingEventArgs e)
            {
                LoadState("L");
            }

            private void Application_Activated(object sender, ActivatedEventArgs e)
            {
                LoadState("A");
            }

            private void Application_Deactivated(object sender, DeactivatedEventArgs e)
            {
                SaveState("D");
            }

            private void Application_Closing(object sender, ClosingEventArgs e)
            {
                SaveState("C");
            }
     

     And then:

            private void SaveState(string when)
            {
                PhoneApplicationService phoneAppService = PhoneApplicationService.Current;
                IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;

                if (phoneAppService.State.ContainsKey("MyValue"))
                {
                    settings["MyValue"] = phoneAppService.State["MyValue"] + " " + when + " ";
                }
                else
                {
                    settings["MyValue"] = when + " ";
                }

            }

            private void LoadState(string when)
            {
                PhoneApplicationService phoneAppService = PhoneApplicationService.Current;
                IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;

                if (settings.Contains("MyValue"))
                {
                    phoneAppService.State["MyValue"] = settings["MyValue"] + " " + when + " ";
                }
                else
                {
                    phoneAppService.State["MyValue"] = when + " ";
                }
            }

    David

  • Series Introduction - Day 1 - Part 1

    Very nice series! I'm about 2/3 of the way through and thoroughly enjoying it. Well Done!

    David

  • Tombstoning and Task Switching - Day 3 - Part 8

    Does App.xaml.cs.SaveState() also need to use TryGetValue, since, the first time it is run, if we leave the page or hit start before we change the TextBox, there is nothing in the property bag and the access fails with an exception?

  • Client Application Services with Visual Studio 2008

    This video was great: fast paced yet complete.

    I did spend a frustrating hour or so trying to figure out why, when I checked the "Remember Me" checkbox, the next call to Membership.ValidateUser(null, null) would result in an exception:

    System.NullReferenceException was unhandled
      Message="Object reference not set to an instance of an object."
      Source="System.Web.Extensions"
      StackTrace:
           at System.Web.ClientServices.ClientFormsIdentity.GetSecureStringFromString(String password)
           at System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider.ValidateUserCore(String username, String password, Int32 rememberMeInt, Int32& promptCount, Boolean tryToUseLastLoggedInUser)
           at System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider.ValidateUserCore(String username, String password, Int32 rememberMeInt)
           at System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider.ValidateUser(String username, String password)
           at System.Web.Security.Membership.ValidateUser(String username, String password)
           at AppServicesClient.Form1.Form1_Load(Object sender, EventArgs e) in C:\Users\drogers\Documents\Visual Studio 2008\Projects\AppServicesDemo\AppServicesClient\Form1.cs:line 39
           at System.Windows.Forms.Form.OnLoad(EventArgs e)
           at System.Windows.Forms.Form.OnCreateControl()
           at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
           at System.Windows.Forms.Control.CreateControl()
           at System.Windows.Forms.Control.WmShowWindow(Message& m)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
           at System.Windows.Forms.ContainerControl.WndProc(Message& m)
           at System.Windows.Forms.Form.WmShowWindow(Message& m)
           at System.Windows.Forms.Form.WndProc(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
           at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
           at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
           at System.Windows.Forms.Control.set_Visible(Boolean value)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.Run(Form mainForm)
           at AppServicesClient.Program.Main() in C:\Users\drogers\Documents\Visual Studio 2008\Projects\AppServicesDemo\AppServicesClient\Program.cs:line 18
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException:

    I found that by replacing the null arguments with string.empty, (Membership.ValidateUser(string.Empty, string.Empty)) the program worked as expected.

    Thanks again and ciao,
    David