Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7165551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:16:08+00:00 2026-05-28T14:16:08+00:00

I have a prism app using RIA services, and my authentication service is in

  • 0

I have a prism app using RIA services, and my authentication service is in a separate RIA class library.

The program works fine at runtime. Authentication and all.

I am getting a nasty error at design time, though, which crashes both visual studio and blend. Blend will crash immediately when I open the solution. Visual studio will crash when I close the particular view (page). At least blend gave me a crash log after though. The error has to do with me setting an instance of my viewmodel as the datacontext of the view in xaml rather than setting/injecting one at runtime.

So when setting a viewmodel datacontext at runtime, the viewmodel constructor is called when the view is loaded in the designer. And when the view is closed the destructor is called. That is where I am getting the exception that crashes vs/blend. So here is the exception:

System.InvalidOperationException: The current instance of WebContext
is not available. You must instantiate a WebContext and add it to
Application.ApplicationLifetimeObjects within the default App
constructor. at
System.ServiceModel.DomainServices.Client.ApplicationServices.WebContextBase.get_Current()
at MyClassLibrary.WebContext.get_Current() at
MyShellProject.ShellViewModel.Finalize()

It’s odd because I am instantiating a WebContext in my App constructor. And there are no problems at runtime. Only since I added an instance of my viewmodel as the datacontext I get the crash at runtime.

So in my App.xaml I have:

<Application.ApplicationLifetimeObjects>
        <MyClassLibrary:WebContext>
            <MyClassLibrary:WebContext.Authentication>
                <ApplicationServices:FormsAuthentication>
                    <ApplicationServices:FormsAuthentication.DomainContext>
                        <MyClassLibrary_Web:MyAuthenticationContext />
                    </ApplicationServices:FormsAuthentication.DomainContext>
                </ApplicationServices:FormsAuthentication>
            </MyClassLibrary:WebContext.Authentication>
        </MyClassLibrary:WebContext>
    </Application.ApplicationLifetimeObjects>

I did also try the code behind equivalent of this in the App constructor. Both have the same result.

This blog post has a little more detail about how my project is set up: http://avcode.wordpress.com/2010/08/25/authenticaion-prism-wcf-ria-services/

Anyone have a clue as to why at design time, visual studio is not aware that I have instantiated a WebContext?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:16:09+00:00Added an answer on May 28, 2026 at 2:16 pm

    Let’s say you have the following variable in ViewModel:

    public bool IsDesignTime
    {
      get
      {
        return DesignerProperties.GetIsInDesignMode(Application.Current.RootVisual);
      }
    }
    

    You can wrap the piece of code which tries to instantiate the WebContext at design time using this variable’s value and return a Mocked object instead. I think WebContext is instantiated when the App is running and connected, not sure though. Late reply but may be useful to someone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an app using SL Prism and MEF using MVVM. I have my
I am creating a Prism 2.1 app in which I have implemented logging, using
I am using prism framework in a silverlight app with multiple modules in separate
I have a multi-select listbox in a SL3 app using prism and I need
I have a prism app where I've added a third party WPF control library
I have a silverlight app using Prism practices; the current code does a search
I have a Silverlight 4 app using Prism 2.2 and I have a few
So I have two separate views in a WPF Prism app. How can I
suppose, we have a Mozilla Prism like XULRunner app. There is a XUL window
The scenario: I have a PRISM application developed in Silverlight (4), and I'm using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.