Answered Prevent Component Code from being executed at Design Time

Robert_Zenz

Well-known member
Joined
Jun 3, 2008
Messages
503
Location
Vienna, Austria
Programming Experience
3-5
Hello.

I wrote a Component which is basically a class. Since it's nice to drag it from the Toolbox I decided to develope it further as a Component. The problem is that the Component get's executed at Design Time. Since it's a UDP-Server Class with Threading etc., it blocks the ports which are specified, and don't even releases them when jumped to Debug Mode.

I already read that I could check of if the executable devenv.exe, but isn't there another way to do that? Like an Attribute which tells him that this Component should be only run at Runtime?

Thanks for your Help,
Bobby
 
Last edited:
Hello John.

Thanks for th reply and the link. Unfortunately this link does not apply to Components, and DesignMode is still buggy. But I've found, based on your hint with the DesignMode-Property, a workaround which seems to work pretty good: DesignMode help?

VB.NET:
If System.ComponentModel.LicenseManager.UsageMode = System.ComponentModel.LicenseUsageMode.Runtime Then
      'this code will only get executed at Runtime
End If[CODE]

Thanks,
Bobby
 
Back
Top