Galin Iliev's blog

Software Architecture & Development

C# Team forthcoming chats in April and May

C# Community Program Manager Charlie Calvert  posted rough schedule about public chats with C# team

 In the April/May time frame there will be three public chats by the C# Team.

April 23, 2007, 11 AM Pacific Time C# Visual Studio IDE Chat: Talk about C# IntelliSense for LINQ. Discuss what else is planned for Visual Studio Orcas. Plus: Code snippets, enhanced IntelliSense, type colorization, refactoring, improved code navigation, metadata as source, Edit and Continue and all the other great new C# IDE features in Visual Studio 2005. There's a lot to talk about! It's your choice! Join the C# IDE team for a chat completely directed by your questions.

May 7, 2007, 11 AM Pacific Time Compiler and Language Chat: C# Language Chat. Want to know more about anonymous delegates in C# 2.0, or our design rationale for them? Have some questions about our current thinking on C# 3.0 and LINQ? Perhaps you'd like to share your ideas with other C# users or the C# language team. Join the C# team chat for an opportunity to do all that and more!

May 21 2007, 11 AM Pacific Time LINQ to SQL Chat: The LINQ Project is a part of the next version of Visual Studio, code named Orcas. LINQ will provide a set of extensions to the .NET Framework that encompass language-integrated query, set, and transform operations. LINQ to SQL is a component of LINQ which allows access to data stored in relational databases. We’re actively designing and developing this technology - show up and join the LINQ to SQL team to participate in that process or just get a better understanding!

Start/Stop IIS Site with C#

Have you ever had you deal with IIS management using C#? I mean IIS6?

for IIS 6 you had to deal with DirectoryEntry class like this (code got from here):

   1:  try
   2:  {
   3:      const string WebServerSchema = "IIsWebServer"; // Case Sensitive
   4:      string ServerName = "localhost";
   5:      DirectoryEntry W3SVC = new DirectoryEntry("IIS://" + ServerName + "/w3svc");
   6:      foreach (DirectoryEntry Site in W3SVC.Children)
   7:      {
   8:          if (Site.SchemaClassName == WebServerSchema)
   9:          {
  10:              Console.WriteLine(Site.Name + " - " + Site.Properties["ServerComment"].Value.ToString());
  11:          }
  12:      }
  13:  }
  14:  // Catch any errors
  15:  catch (Exception e)
  16:  {
  17:      Console.WriteLine("Error: " + e.ToString());
  18:  }

and once you find your site you had to execute DirectoryEntry.Invoke("Start", null) or DirectoryEntry.Invoke("Stop", null)  in order to start/stop the site.

Not very convinient but works :).

Well with IIS7 there are a good news and bad news... The bad news is this code won't work on IIS7 (and Vista).

The good news is that there is new .NET assembly () for managing IIS. It is located in %WinDir%\System32\InetSrv\Microsoft.Web.Administration.dll. It contains some wrapper classes that makes dev life much easier :)

with it the task above become:

   1:  ServerManager iisManager = new ServerManager();
   2:  iisManager.Sites["NewSite"].Stop(); 

Much prettier huh?! :)

for more info about Microsoft.Web.Administration.dll read CarlosAg blog's entry Microsoft.Web.Administration in IIS 7

Microsoft gives lessons how to design class libraries

MSR Technical Education Series: Designing .NET Class Libraries

Krzysztof Cwalina (co-author of Framework Design Guidelines) recently did a talk for the Microsoft Research Group on great framework design. 

I heard somewhere that .NET Framework started from about 6000 classes in version 1.0 and grew to 18 000 classes in version 3.0. I am not sure how precise are these numbers but they could give rough idea how big is .NET. All these classes should had been carefully designed so watch this video where Krzysztof Cwalina (program manager, .NET Framework Team, Microsoft) esplains how to design such libraries.

The video is more than 3 hours but I am sure it worths.

(via Brad Adams blog)

Sofia.NET UG meeting

Last week I had a talk on monthly meeting of Sofia.NET User group. The meeting was held in Microsoft Bulgaria office.

There was also beer and snacks kindly provided by Microsoft. There was also presents for the atendees :) You can take a look at pictures taken by Ruslan.

As I promised I publish slides and demos so everyone who is interested could play with them :)

Sofia.NET is free professional group so everyone is invited. If you want to become member and attend on our meetings register here.

C# 3.0 Compiler milestones

Luke Hoban, Program Manager for the C# Compiler posted blog article how is schedulled job for C# 3.0 compiler. This show what are new things and when we could expect to touch them:

Milestone 1

Our first goal was to get the most fundamental new language features implemented, so we could begin building LINQ applications with the Orcas compiler as early as possible.  Many of the features in this first set were also chosen because they were pre-requisites for implementing some of the later language features.  For example, lambdas were important to get in early, because the conversion of lambdas to expression trees depended on this.  Here's what we built first:  

  • Local Variable Type Inference (var)
  • Lambdas
  • Object Initializers
  • Extension Methods (usage)

Milestone 2

For our second milestone, our goal was to replace the C#3.0 prototype compiler that we had shipped with the May 2006 CTP.  When we finished this milestone, we actually moved all of the teams internally who were using C#3.0 over to use the Orcas C# compiler.  This required implementing:

  • Lambdas bound to Expression Trees
  • Extension Methods (definition)
  • Collection Initializers
  • Anonymous Types
  • Query Expressions

Milestone 3

The third milestone was shorter, and our goal for this milestone was to get to a good state for the first Beta.  The results of this milestone are what you'll see in the Orcas February/March CTP and the first Orcas Beta.  We also implemented one of the most requested language features in the history of C# - auto-implemented properties!

  • Auto-Implemented Properties
  • Enhancements to Collection Initializers
  • Non-language features, such as debuggability improvements

Milestone 4

We're now working on the last feature milestone for Orcas.  We're finishing off with one more language feature and a lot of work to improve compiler fundamentals, such as error messages and performance.  Note that this work won't make it into the first Beta:

  • Partial Methods
  • Compiler Error Message Improvements
  • Compiler Performance
  • Compiler Generated IL Performance

It seems most of the features are implemented and we could see them in CTPs. We can touch most of them except Partial Methods. It looks like MS shaped the main VS Orcas features and they will shine them in next months before they release version 9.


Windows Forces you to use UAC to Add a Printer

I've been using Vista since beta 2 but I haven't had my network printer installed up to now.

Everytime I tried to install network printer I get the message saying: "Windows cannot connect to the printer. The specified print monitor is unknown." with the following screen.

I finally found solution on this here and here.

Simply said if you're in same situation then you must turn on UAC. Yes, you need UAC in order to install network printer. Once installed you can turn it off again.

Here was some intersting suggestion from javmirin:

In Vista PC's go to "Control Panel" - "Printers" - "Add printer".
Believe or not, click "Add a local printer" (I know you want to add a network printer but that way it doesn't work).
Click "Create a new port" - "Local Port" - "Next"
In the next box you have to enter a port name like this:
\\PC name\Printer name
where "PC name" is the network name of the XP PC where you have the printer and "Printer name" the network name of that printer. Be careful with this names. Check in your XP PC "Control Panel" - "Printers and faxes" - "your printer" - right click - "share" - "share resources name"
(sorry I'm translating from Spanish and not sure these are the exact terms).



Visual Studio Codename "Orcas" timetable

Visual Studio Codename "Orcas" timetable was released on MSDN2.

Here is it:

Visual Studio code name "Orcas"

In addition to developer productivity improvements and new supported platforms and technologies in Visual Studio, Visual Studio code-named “Orcas” release will include the following new scenarios, features and improvements to Visual Studio Team System.

Projected Availability:

  • Beta 1 - 2nd Quarter, CY 2007
  • Beta 2 - Mid-year CY 2007
  • RTM - TBA

It seems we will have more stable releases soon :)

C# architect Anders Hejlsberg does ... VB on MVP summit

I came across Jim Wooley's blog where C# architect Anders Hejlsberg does demo with VB. :)

I find this very interesting and I decided to share with you :)

I have nothing against VB (except a few thigs :) ) and I do VB from time to time because of specific tasks. The biggest VB advantage against C# is optional parameters. To do this in C# you will have to declare buch of methods overloads.

I don't want to turn this into discussion which one is better. I just find interesting Wooley's post Anders does VB!

Protect your ASP.NET website from DoS attack

DoS is not Disk Operating System :). This stands for Denial of Service attack and briefly described is when to many calls are made to your service so it stops responding to intented users/customers. for more info see Wikipedia.

MS MVP Omar AL Zabir wrote good blog entry about how to prevent DoS attacks on ASP.NET sites and expecially web services.

When you make good ASP.NET application and clear most of the bugs (yep nobody is perfect) it is time to adjust it to be high available and fast respondible Prevent Denial of Service (DOS) attacks in your web application is good start to protect your creation from so called hackers attacks :)


Enable RibbonX intellisense in Visual Studio

I had interesting experince with customizing Ribbon within VS 2005.

At first place I was able to get very helpful intellisence in VS IDE. After some time I had to edit .xml fiel but... no intellisense. well ... what to do?!

I intalled VSTO - I didn;t have it after last reinstall. and bingo - I've got it again... until today...

What happened?! Why?!  I just don't know - (probably most of us hears customer, friends and relatives that phone us with strange PC question and says - Yesterday it worked and I haven't touched anything! :)  ) Same thing here :)

But I know how to enable that intellisense again. And this is how:

  1. You need customUI.xsd and Visual Studio 2005 :)
  2. place customUI.xsd in %programfiles%\Microsoft Visual Studio 8\Xml\Schemas  and this is it. You must have it.

There are some other ways to enable intellisence for xml in VS 2005. You can find them on Aaron Stebner's blog post.