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 737991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:47:08+00:00 2026-05-14T07:47:08+00:00

My custom controls are not loading in VS.NET’s designer because of a null reference

  • 0

My custom controls are not loading in VS.NET’s designer because of a null reference exception. It’s got everything to do with the way I am retrieving the baseUri of the application when it runs in the browser:

_uriPrefix = Application.Current.Host.Source.AbsoluteUri.Substring(0,
     Application.Current.Host.Source.AbsoluteUri.IndexOf("/ClientBin")).Trim();

According to the exception details and the help file I’m directed to (here) I’m not correctly designing my app for a runtime that’s not the browser (i.e. the new WPF editor in VS.NET or Expression Blend).

So, the question is how do retrieve the baseUri (the http://localhost:#### part of my application) if I can’t use Application.Host which apparently is null during design time? is there a safe way to do this so I can load my custom controls in a designer?

  • 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-14T07:47:08+00:00Added an answer on May 14, 2026 at 7:47 am

    Duh! I hate/love when I do this. I’m answering my own question (again). I can use the DesignerProperties.IsInDesignTool boolean to test if I’m in design mode or not:

    if (!DesignerProperties.IsInDesignTool)
         _uriPrefix = Application.Current.Host.Source.AbsoluteUri.Substring(0,
              Application.Current.Host.Source.AbsoluteUri.IndexOf("/ClientBin")).Trim();
    

    Now I can view my custom control in the new VS 2010 editor. Yeah!

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

Sidebar

Related Questions

I have some custom user controls in my .net winforms program that do not
Is there a way to create custom controls in a .Net Language for use
Two way binding does not work on my custom control with the following internals:
I have a question about viewstate and custom controls in asp.net. Say I have
I'm writing a custom class library that contains custom controls (not user controls). I
In OS 3.1, Apple provides a way to overlay custom controls on the camera
I am dynamically adding custom controls in Silverlight 2 but they are not visible.
I am in the process of beginning work on several ASP.NET custom controls. I
We have an ascx custom control (not a web part) hosted in a special
I wrote a custom control inherited from WebControl. (Note: not a user control). 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.