Can I write CGI applications using .NET
You sure can. Here is a simple CGI program that prints out the current time and also all the environment variables that are available to it. using System; public class cgi { public static void Main(string[] args) { Console.WriteLine(‘Content-Type:text/html\n\n’); if(args.GetLength(0) == 0) Console.WriteLine(‘The time now is {0}’, System.DateTime.Now.ToString()); else Console.WriteLine(‘Hi {0}, the time now is {1}’, args[0], System.DateTime.Now.ToString()); foreach(string s in Environment.GetEnvironmentVariables().Keys) Console.WriteLine(‘ {0} : {1} ‘,s, Environment.GetEnvironmentVariables()[s]); } }
How do you invoke a COM Class in a specific COM DLL in .Net
Imtiaz Alam discusses both early and late binding techniques in his article entitled Accessing COM+ component using C# on C# Corner.
How to make properties in your custom data type appear in a particular order in the property browser
// Your custom data type public class MySize { … public int Width{get{…}set{…}} public int Height{get{…}set{…}} } For example, in the above class (MySize) if you want to your properties ‘Width’ and ‘Height’ to appear in that order, you should provide this override: public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; } public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { System.ComponentModel.PropertyDescriptorCollection propertyDescriptorCollection; string[] propNames; propertyDescriptorCollection = TypeDescriptor.GetProperties(typeof(System.Drawing.Size),attributes); propNames = (string[])new System.String[2]; propNames[0] = @’Width’; propNames[1] = @’Height’; return propertyDescriptorCollection0.Sort(propNames); } // end of method GetProperties
How do you make your custom data types property browser browsable when contained in a Control/Component (as a property)
// Your custom data type public class MySize { … public int Width{get{…}set{…}} public int Height{get{…}set{…}} } public class MySizeConverter: ExpandableObjectConverter { public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) { return true; } public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) { MySize size = new MySize(); size.Width = (int)propertyValues[(object)’Width’]; size.Height = (int)propertyValues[(object)’Height’]; return (object)size; }
How do you detect the designer host getting loaded for the first time in your designer
Subscribe to IDesignerHost.LoadComplete event. Make any changes to the designerhost (like adding/deleting component, etc.) only after this event, or else the design document will not be made ‘dirty’. (IdesignerSerializationManager.SerializationComplete will tell you when Code is deserialized into design time components).