Display .Net codes on blog with nice format

While I was trying to display nicely formatted .Net codes on my blog I found CopySourceAsHtml which is a Visual Studio plugin.

If you want to try please download and it’s installed simply. The code on your blog looks exactly like it would in Visual Studio. It also works with almost any blog which is just Html there is nothing that needs to be done on the server.

How to use it

In Visual Studio, Just select the code you want to display -> right click -> select Copy As HTML. A clean HTML representation of you code will be copied onto the clipboard which can then be pasted into your blog editor.
I like Windows Live Writer as my blog editor which I can save in local first before publish to online and there are many good plugins are available.
It supports with Visual Studio 2005 for now. So if you are using newer version which is Visual Studio 2008 then.

How to make CopySourceAsHtml works with Visual Studio 2008

Currently there is no Visual Studio 2008 version of this Add-in available to download but it is very easy way to make it works with VS 2008.
In the Addins path of VS 2005
(If you are using Window Vista it is usually in C:\Users\USERNAME\Documents\Visual Studio 2005\Addins)
You will find the following files:

  • CopySourceAsHtml.dll
  • CopySourceAsHtml.AddIn
  • CopySourceAsHtml.dll.config
  1. Copy those files to the Addins path for VS 2008
  2. Open CopySourceAsHtml.AddIn file in a text or XML editor in the Addins folder of VS 2008
  3. Change as seen below and save the changed file back into the VS 2008 Addins folder.
    The original file contained text <Version>8.0</Version> instead of <Version>9.0</Version>

    <?xml version="1.0" encoding="UTF-16" standalone="no"?>
    <Extensibility xmlns="http://schemas.microsoft.com/AutomationExtensibility">
        <HostApplication>
            <Name>Microsoft Visual Studio Macros</Name>
            <Version>9.0</Version>
        </HostApplication>
        <HostApplication>
            <Name>Microsoft Visual Studio</Name>
            <Version>9.0</Version>
        </HostApplication>
        <Addin>
            <FriendlyName>CopySourceAsHtml</FriendlyName>
            <Description>Adds support to Microsoft Visual Studio 2005 for copying source code, syntax highlighting, and line numbers as HTML.</Description>
            <Assembly>CopySourceAsHtml.dll</Assembly>
            <FullClassName>JTLeigh.Tools.CopySourceAsHtml.Connect</FullClassName>
            <LoadBehavior>5</LoadBehavior>
            <CommandPreload>0</CommandPreload>
            <CommandLineSafe>0</CommandLineSafe>
        </Addin>
    </Extensibility>
    
  4. In Visual Studio 2008 go to Tools -> Add-in-Manager -> Activate the AddIn

Now you can get CopySourceAsHtml works with Visual Studio 2008.

No comments as yet.

Anonymous - Gravatar

No comments have yet been made to this posting.

Commentors on this Post-

Leave a Comment-

Comment Guidelines: Basic XHTML is allowed (a href, strong, em, code). All line breaks and paragraphs are automatically generated. Off-topic or inappropriate comments will be edited or deleted. Email addresses will never be published. Keep it PG-13 people!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

All fields marked with "*" are required.