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

  • Home
  • SEARCH
  • 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 5951397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:31:52+00:00 2026-05-22T17:31:52+00:00

im passing my webservice url to my silverlight application via the parameters. when my

  • 0

im passing my webservice url to my silverlight application via the parameters.

when my application launches it creates the viewmodel for the mainpage before it application_startup event is fired.

in my viewmodel constructor i have a call to my serviceagent to load some data from the webservice, but the webservice url is not initialised yet due the the viewmodel being constructed before the application_startup event is raised. whats the best way to get around this. Its a friday evening and my brain seems to be pretty fried trying to think of a good solution.

An instance of the ViewModelLocator is created in the app.xaml

<vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" />

Then in the ViewModelLocator constructor there is a call to create the main page

    public ViewModelLocator()
    {
        CreateMain();
    }

    public static void CreateMain()
    {
        if (_main == null) _main = new MainViewModel();
    }

and in my MainViewModel i make a call to my serviceagent

    public MainViewModel() : this(new MyServiceAgent()) { }

    public MainViewModel(IMyServiceAgent myServiceAgent)
    {
        if (IsInDesignMode)
        {

        }
        else
        {

            ServiceAgent = myServiceAgent;         
            ServiceAgent.GetData();

            RegisterMessageListeners();
            WireUpCommands();
        }
    }

App.xaml.cs

    public App()
    {
        Startup += Application_Startup;
        Exit += Application_Exit;
        UnhandledException += Application_UnhandledException;

        InitializeComponent();
    }

    private void Application_Startup(object sender, StartupEventArgs e)
    {
        if (e.InitParams != null && e.InitParams.Count > 0)
            ParseInitParams(e.InitParams);

        RootVisual = new MainPage();
        DispatcherHelper.Initialize();
    }

Cheeers

  • 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-22T17:31:53+00:00Added an answer on May 22, 2026 at 5:31 pm

    to fix my issue i had to remove the line of code from the viewmodellocator constructor that was initialising the MainViewModel

    public ViewModelLocator()
    {
        //CreateMain();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am passing 4 Parameters to an asp.net Webservice. This is my Code so
I am having a problem in passing parameters to webservice which except POST data
when passing parameters after index.php its showing 404 error .. its apache error not
Sometimes, you may need to call a 'login' url, passing in some sort of
I have a Webservice(API) which I am passing to the DOM parser and it
I have to send the following data to webservice at URl The format of
I wold like to save the given webservice url as xml file for offline
I'm having a bit of difficulty passing a reference type between webservices. My set
I'm work with GWT and parsing a JSON result from an ASP.NET webservice method
Passing User defined argument to RPM is possible while installing?. for example: ~>rpm -i

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.