How to Get IIS Web Sites Information Programmatically

I needed to get the location of IIS log files on my servers, after doing a quick investigation, I am quite amazed on how much information are exposed via managed code. This snippet will return the name of the sites and the location of the log files. foreach (DirectoryEntry Site in new DirectoryEntry("IIS://" + System.Environment.MachineName…


How to Install Windows Service Programmatically

Sometimes you may want to install a Windows Service programmatically, but the target machine does not have InstallUtil.exe. To install a Windows Service programmatically, you can build an application to install that Windows Service. Add a reference to System.Configuration.Install Use this code: public static void InstallService(string ExeFilename) { System.Configuration.Install.AssemblyInstaller Installer = new System.Configuration.Install.AssemblyInstaller(ExeFilename); Installer.UseNewContext =…

10

How to Install Assemblies to the GAC Programmatically?

You can add or remove assemblies from the GAC using code. You can use Publish.GacInstall method to install an assembly to the GAC, or Publish.GacRemove method to remove that assembly from the GAC. If you are using Vista, and enable UAC, you have to run this code using elevated command (run as Administrator), otherwise it…


In God We Trust, Everybody Else Must Bring Data

One day, I was presented with a problem, that the finalizer was not called during application pool recycle. I was busy, so I did not have chance to respond. Later on, I checked the code, it was modified to inherit from CriticalFinalizerObject class, and a comment saying that even though the class is inherited from…


The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error

I am playing around with WCF, and I got that error message above. Searching did not really help in defining what was going on. And yes, it was working on my previous test environment. 🙂 Luckily, I still had one of my test method, which just ping the service and did nothing else. That method…


Editing Share Permission

In my previous post, I have shown you how to set up permission on a share. The thing with Win32_Share, when you set the permission, you basically overwrites the existing permission. If you want to edit permission on the share (grant a new user access to the share, or revoke an existing user’s permission), then…

3

Common AccessMask value when Configuring Share Permission Programmatically

In my previous post, I have shown you how to modify share permission using .Net framework. Access Mask is quite granular, most likely you will need to assign a particular user as ‘Full Control’, ‘Change’, or ‘Read’. In Vista or Server 2008, it will be ‘Co-Owner’, ‘Contributor’, or ‘Reader’. The literal values for those permissions…


Programmatically Configuring Permissions on a Share

I was asked this problem on how to set up permission for a share programmatically using .Net Framework. Well, I am not aware of any API that can do that. Searching does not return any good result. There are lot of resources on how to configure permission settings for local folder, but not so much for UNC path. At the end,…

35

WCF Webcast

Michele Leroux Bustamante made fifteen great Webcasts, hosted by msdn. If you are learning WCF, I highly recommend these Webcasts and her book, Learning WCF. http://www.dasblonde.net/2007/06/24/WCFWebcastSeries.aspx


CustomActionData and User Defined Path

When designing a setup project, you can define text boxes dialog to input a file system path. To process the input that the user has entered, usually a custom action is created to handle the user input, and the user input is passed through CustomActionData property. Unfortunately, there are several problems when dealing with path….

7