How to distinguish design time from run-time?

Posted on 2008-11-13
Last Modified: 2012-05-05
I am using the code below, but I want to know is there a better way to check if I am in design time?
if( System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv" )




Open in new window

Question by:HOVE
    LVL 7

    Accepted Solution


    1.) Call GetService(typeof(IDesignerHost)) and see if it returns something.

    2.) System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    Nevermind...I misread the question.   =\

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now