Thursday, March 24, 2011

Design-Time validation of library

I have a library that I would like to license and distribute.

I know how to license a class/library for runtime. I've done that several times, actually. I know how to license a user control. I've also done that several times.

What's got me stumped is how to license a library (that has no drag/drop user control or component) for development only. How do you license a library for design-time?

Any thoughts/hints?

From stackoverflow
  • I finally found the answer. This one isn't as apparent as I thought it would be.

    Instead of looking for DesignTime or RunTime attributes, you need to see if a debugger is attached.

    Drop this in the constructor (with the appropriate attributes on your class), and you're off and running!!

    if (System.Diagnostics.Debugger.IsAttached)
    {
        License L = LicenseManager.Validate(typeof(MyControl), this);
    }
    

    I hope this helps someone else with the same issue!!

    --Jerry

  • You could use LibraryManager.UsageMode to determine if you are running at design time. I assume you wish to check for a debug run also from the answer you posted.

0 comments:

Post a Comment