Monday, December 3, 2007

Free ASP.NET Rich Text Editor control

Check out this awesome free rich text editor. The source code can be found at CodePlex at: RTE (Rich Text Editor) ASP.NET Control

The project page lists the following features 

Supported Browsers: Internet Explorer and FireFox
Supported Styles / Formats: Bold, Italic, Underline, Justify, indentations, Plain Lists, Numbered Lists
Supported Commands: Copy, Paste, Cut, Add Hyperlink, Set Foreground Color, Set Highlight Color, Set Fonts, Set Font Sizes, Insert Smiles
Supported Views: Text View, Html View

You can see a demo on this page: http://rteditor.members.winisp.net/

Technorati Tags:

Visual C# 2008 shortcuts

I found a nice PDF file that lists the most frequently used shortcuts in Visual C# 2008. You can download it from the Visual C# 2008 Keybinding Reference Poster page. I haven't had the time to check how many shortcuts differ from those in Visual C# 2005.

If you are using Visual C# 2005 check out this post: Visual C# 2005 shortcuts

Technorati Tags: , , ,

Friday, September 28, 2007

Partial methods

Visual Studio 2008 allows the use of partial methods. Partial methods are nothing but a compiler trick (just like partial classes). Designer generated code can provide hooks into their class methods, by using the partial keyword. Users of the class can then hook into those methods and provide their own implementation. When a partial method has no body then the partial method is not emitted to metadata. So in a sense they are optional methods.

Check out this video on partial methods titled: Partial Methods in C#3 and VB9 by Daniel Moth. In it he explains what partial methods are and their limitations. He also compares them to the Conditional attribute and event handlers.

Technorati Tags: ,

Friday, September 7, 2007

External settings file for ClientSettingsSection (applicationSettings)

Very often we define application settings in application configuration sections and would like to isolate the configuration section into an external settings file. Creating external settings file using the configSource attribute for the predefined configuration sections (AppSettings, ConnectionStrings etc) is well documented. But the literature for custom configuration section is sparse.

Listed below is a sample configuration file that contains a configSource attribute being used in a ClientSettingsSection. I have kept only the essential parts of the file:

   1: <configSections>
   2:   <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup">
   3:     <section name="MyApplication.Properties.Settings" type="System.Configuration.ClientSettingsSection"/>
   4:   </sectionGroup>
   5: </configSections>
   6:  
   7: <applicationSettings>
   8:   <MyApplication.Properties.Settings configSource="BusinessLogic.config" />
   9: </applicationSettings>

Line 8: Using the configSource attributed to define an external settings file called "BusinessLogic.config"


A couple of things of note:
- Unlike how it does for predefined configuration sections, Visual Studio does not provide intellisense when trying to add the configSource attribute to ClientSettingsSection.
- The external settings file has to be in the same directory or subdirectory as the configuration file. So line 8 can be replaced with the following line:


<MyApplication.Properties.Settings configSource="ConfigFiles\BusinessLogic.config" />

Listed below is the "BusinessLogic.config" file


   1: <MyApplication.Properties.Settings>
   2:   <setting name="InitializationVector" serializeAs="String">
   3:     <value>1234567890abc!@#</value>
   4:   </setting>
   5:   <setting name="KeySize" serializeAs="String">
   6:     <value>256</value> 
   7:   </setting>
   8: </MyApplication.Properties.Settings>

 

Technorati Tags: , ,

Thursday, September 6, 2007

Getting line numbers in exception stack trace in a Windows Service

The Exception.ToString() method contains call stack information when the exception was thrown. However if the PDB files from the assemblies involved are available, this information also contains file names and line numbers at each level of the stack trace. Needless to say that this information can be very beneficial to the developer.

The CLR will look for the PDB files in the runtime working directory, which for most applications is the installation directory itself. However for windows services the working directory is the windows systems32 directory (For eg: C:\Windows\System32). So exceptions thrown in assemblies that are hosted in a windows service, the call stack rarely contains the file names and line numbers even when the right PDB files are available.

The working directory of a windows service can be changed using the following line:

   1: Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory;

Once the working directory has been changed to the base directory, the CLR should pick up the right PDB files and the stack trace should contain line numbers.


Technorati Tags: , , ,

Friday, August 31, 2007

Shortcut: Launch Visual Studio Command Prompt from Visual Studio

In Visual Studio 2005:

  1. Go to Tools > External tools
  2. Click Add and enter the following information
    1. Title: Cm&d
    2. Command:  %comspec%
    3. Arguments: /k ""C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat"" x86
    4. Initial Directory: $(ItemDir)
  3. Click Apply / OK 

In Visual Studio 2008:

  1. Go to Tools > External tools
  2. Click Add and enter the following information
    1. Title: Cmd
    2. Command:  %comspec%
    3. Arguments: /k ""C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"" x86
    4. Initial Directory: $(ItemDir)
  3. Click Apply / OK

Technorati tags: ,

Wednesday, August 29, 2007

Visual C# 2005 shortcuts

I found a nice PDF file that lists the most frequently used shortcuts in Visual C# 2005. You can download it from the Visual C# 2005 Keyboard Shortcut Reference Poster page.

Technorati Tags: ,

Subscribe to my feed in your favorite feed reader