Welcome to MSDN Blogs Sign in | Join | Help

Browse by Tags

All Tags » .Net Framework   (RSS)

Attaching an Event Handler

Whenever I need to attach an event handler, usually I use one of these methods, a delegate, anonymous method, or lambda expression. For complex events (more than 3 lines of code), I create a separate method. If the method is short, I use anonymous method.
Posted by HelloWorld | 0 Comments
Filed under:

How to Give Authenticated Users or Everyone Access to Your Share Programmatically

Another follow-up from my previous article, Programmatically Configuring Permissions on a Share , David B asked a question, how to share a folder to Everyone, instead of to a specific users. This article will answer that question, based on the code on
Posted by HelloWorld | 0 Comments

How to Programmatically Modify the IIS Virtual Directory

If you have more than a dozen web servers in a cluster with identical setting, and you need to update the virtual directory, it is much more convenient to write a simple program to update it. This example shows how to do it. In this case, this snippet

C# 3.0 Automatic Property

C# introduces a number of syntactic sugar, including Automatic Property link . A question was asked, why is this useful, what is the advantage of this approach compared to exposing the field as public field? The advantage of the automatic property is
Posted by HelloWorld | 10 Comments

Fixing the Issue that Does Not Exist

I spent some time planning on improvements that I wanted to do on one of our project. I reviewed the code that I notice a place where I think I could improve the performance by avoiding locking. So I wrote the code, and tested it, works great, the new

Writing Fast Code (Resources)

This article is intended to help me remember where can I find these resources, also kind of helpful should I need to forward this to someone. Hopefully, this post will be continuously updated. Managed code is very fast in allocating memory, the problem

When Building Multi-Threaded Applications using ThreadPool, Make the Number of Worker Threads Configurable

Just a simple thought, when creating a multi-threaded applications, make the number of threads configurable. ThreadPool has this behavior that it will immediately set the minimum worker threads equal to the number of logical processors in your machine,

String.Split has High Cost on Performance

One application had a memory issue, it just consume too much resources. The application performed well, but it is very obvious when we saw the performance counters, something can be done to make it better. Reviewing the code did not reveal something significant,
Posted by HelloWorld | 0 Comments

How to Create Custom Event Log for Windows Service

When you created a Windows Service, you usually add a Service Installer to allow this service to be installed using InstallUtil or installing it programmatically like this post shows you. The service installer will create the Event Log for the service,

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

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

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

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

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
Posted by HelloWorld | 0 Comments

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
Posted by HelloWorld | 1 Comments
More Posts Next page »
 
Page view tracker