Mark's profileMark's .Net Code SpaceBlogListsGuestbook Tools Help

Mark's .Net Code Space

Getting the most from .Net

Mark Howell

Occupation
Location
Interests
I'm a hard core software developer with over 20 years of experience in everything from low level assembly on both mainframes andPCs to 4GL, project management, growth planning, technological analysis and application and much more.
Mastering Regular Expressions
Inside the Microsoft® Build Engine: Using MSBuild and Team Foundation Build (PRO-Developer)
Microsoft® Windows PowerShell(TM) Step By Step (Step By Step (Microsoft))
Introducing Microsoft Silverlight 2.0, 2nd Edition
Foundation Expression Blend 2: Building Applications in WPF and Silverlight (Foundation)
Windows(R) PowerShell Unleashed
CLR via C#, Second Edition (Pro Developer)
JavaScript for Dummies
Essential ASP.NET With Examples in C# (Microsoft .NET Development Series)
Microsoft  Windows  Workflow Foundation Step by Step (Pro Step By Step Developer)
Microsoft Windows PowerShell Programming for the Absolute Beginner
Head First C# (Brain-Friendly Guides)
Applied Microsoft® .NET Framework Programming (Pro-Developer)
Inside C#, Second Edition
Professional Team Foundation Server
A Developer's Guide to SQL Server 2005 (Microsoft .NET Development Series)
Pro Visual Studio 2005 Team System Application Development (Pro)
Just quick tidbits
Thanks for visiting!
Please wait...
Sorry, the comment you entered is too long. Please shorten it.
You didn't enter anything. Please try again.
Sorry, we can't add your comment right now. Please try again later.
To add a comment, you need permission from your parent. Ask for permission
Your parent has turned off comments.
Sorry, we can't delete your comment right now. Please try again later.
You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
Complete the security check below to finish leaving your comment.
The characters you type in the security check must match the characters in the picture or audio.

Quote of the Day

Loading...

Weather

Loading...
September 15

A .Net 4.0 tidbit to whet your excitement!

This is just a very tiny item to stoke the coals of your excitement about the .Net 4.0!

 

I know this will seem pretty simple but dealing with COM objects or DOM or other externally bound type structures can be pretty tedious if you cannot statically bind to those type libraries.   For example, if you are calling a Calculator object, if you can statically bind and invoke, the code is pretty simple:

 

       // Static Invocation

       Calculator calc = GetCalculator();

       int sum = calc.Add(10, 20);

 

 

However, if you cannot statically bind, you have to go thru the tedious way of doing dynamic invocation.   The code would looks something like this:

 

       // v3.x .Net Dynamic Invocation

       object calc = GetCalculator();

       Type calcType = calc.GetType();

       object result = calcType.InvokeMember("Add", BindingFlags.InvokeMethod, null, new object[] { 10, 20 });

       sum = Convert.ToInt32(result);

 

 

The above works, but the code is messy and will look somewhat different across the different languages.  Here comes .Net 4.0 DLR!!  With the new dynamic keyword the code not only becomes MUCH simpler, but is almost consistent across the languages!!!  Take a look!

 

       // v4.0 .Net Dynamic Invocation using the DLR!

       dynamic calc = GetCalculator();

       sum = calc.Add(10, 20);

 

 

This is exciting stuff!    Happy Coding!!

August 21

PowerCommands for Visual Studio 2008

I found a handy set of tools for VS 2008 IDE.   One of my favorites is the "Collapse Projects"!  Why this isn't already in the IDE, I have no idea.  But here is the link and a list of commands:

 

http://code.msdn.microsoft.com/PowerCommands

 

 

Below is a list of the included in PowerCommands for Visual Studio 2008 version 1.1. Refer to the Readme document for additional command details and screenshots.

Enable/Disable PowerCommands in Options dialog
This feature allows you to select which commands to enable in the Visual Studio IDE. Point to the Tools menu, then click Options. Expand the PowerCommands options, then click Commands. Check the commands you would like to enable.
Note: All power commands are initially defaulted Enabled.

Format document on save / Remove and Sort Usings on save
The Format document on save option formats the tabs, spaces, and so on of the document being saved. It is equivalent to pointing to the Edit menu, clicking Advanced, and then clicking Format Document. The Remove and sort usings option removes unused using statements and sorts the remaining using statements in the document being saved.
Note: The Remove and sort usings option is only available for C# documents.
Note: Format document on save and Remove and sort usings both are initially defaulted OFF.

Clear All Panes
This command clears all output panes. It can be executed from the button on the toolbar of the Output window.

Copy Path
This command copies the full path of the currently selected item to the clipboard. It can be executed by right-clicking one of these nodes in the Solution Explorer:
The solution node; A project node; Any project item node; Any folder.

Email CodeSnippet
To email the lines of text you select in the code editor, right-click anywhere in the editor and then click Email CodeSnippet.

Insert Guid Attribute
This command adds a Guid attribute to a selected class. From the code editor, right-click anywhere within the class definition, then click Insert Guid Attribute.

Show All Files
This command shows the hidden files in all projects displayed in the Solution Explorer when the solution node is selected. It enhances the Show All Files button, which normally shows only the hidden files in the selected project node.

Undo Close
This command reopens a closed document , returning the cursor to its last position. To reopen the most recently closed document, point to the Edit menu, then click Undo Close. Alternately, you can use the CtrlShiftZ shortcut.
To reopen any other recently closed document, point to the View menu, click Other Windows, and then click Undo Close Window. The Undo Close window appears, typically next to the Output window. Double-click any document in the list to reopen it.

Collapse Projects
This command collapses a project or projects in the Solution Explorer starting from the root selected node. Collapsing a project can increase the readability of the solution. This command can be executed from three different places: solution, solution folders and project nodes respectively.

Copy Class
This command copies a selected class entire content to the clipboard, renaming the class. This command is normally followed by a Paste Class command, which renames the class to avoid a compilation error. It can be executed from a single project item or a project item with dependent sub items.

Paste Class
This command pastes a class entire content from the clipboard, renaming the class to avoid a compilation error. This command is normally preceded by a Copy Class command. It can be executed from a project or folder node.

Copy References
This command copies a reference or set of references to the clipboard. It can be executed from the references node, a single reference node or set of reference nodes.

Paste References
This command pastes a reference or set of references from the clipboard. It can be executed from different places depending on the type of project. For CSharp projects it can be executed from the references node. For Visual Basic and Website projects it can be executed from the project node.

Copy As Project Reference
This command copies a project as a project reference to the clipboard. It can be executed from a project node.

Edit Project File
This command opens the MSBuild project file for a selected project inside Visual Studio. It combines the existing Unload Project and Edit Project commands.

Open Containing Folder
This command opens a Windows Explorer window pointing to the physical path of a selected item. It can be executed from a project item node

Open Command Prompt
This command opens a Visual Studio command prompt pointing to the physical path of a selected item. It can be executed from four different places: solution, project, folder and project item nodes respectively.

Unload Projects
This command unloads all projects in a solution. This can be useful in MSBuild scenarios when multiple projects are being edited. This command can be executed from the solution node.

Reload Projects
This command reloads all unloaded projects in a solution. It can be executed from the solution node.

Remove and Sort Usings
This command removes and sort using statements for all classes given a project. It is useful, for example, in removing or organizing the using statements generated by a wizard. This command can be executed from a solution node or a single project node.

Extract Constant
This command creates a constant definition statement for a selected text. Extracting a constant effectively names a literal value, which can improve readability. This command can be executed from the code editor by right-clicking selected text.

Clear Recent File List
This command clears the Visual Studio recent file list. The Clear Recent File List command brings up a Clear File dialog which allows any or all recent files to be selected.

Clear Recent Project List
This command clears the Visual Studio recent project list. The Clear Recent Project List command brings up a Clear File dialog which allows any or all recent projects to be selected.

Transform Templates
This command executes a custom tool with associated text templates items. It can be executed from a DSL project node or a DSL folder node.

Close All
This command closes all documents. It can be executed from a document tab.

 

 

Great stuff!  Happy Coding!

 

 

July 20

Visual Studio SP1 IDE Crashes

I have not been immune to the tortuous IDE crashes in Visual Studio SP1.  Thankfully, enough screams have been raised that a fix is available.  Somehow I missed this back in May.  Hopefully, the rest of you won't miss it even longer than I have.  You can find the information about it here along with the associated hotfix.  Just make sure that you are suffering from the problem indicated before installing.

Happy Coding!

 

July 13

Quirks working with Workflow Designer

When working with Windows Workflow Foundation projects, it's easy to get into the routine of working with your activities in the designer.  This is all great and wonderful until the complexity increases.  For example, if you have activities that are sequential workflow units themselves, this can lead to some real 'Workflow Designer Heartburn'. One example, I have a large application with many workflow activities that are sequential workflow units themselves.  If I create yet another activity that is a 'Code' activity (as opposed to code behind), then the current VS 2008 designer will sometimes just flat refuse to let me drop other sequential workflow code activities into it.  To get around this, you can create a code behind activity.  For some reason, the designer seems to have less problems with this.  I'm just hoping that some of these designer issues are addressed in the forthcoming VS2010.
 
Happy Coding
 
March 05

Great things coming to Windows Workflow 4.0!!!

What’s new in .NET Framework 4.0

 

·         Next versions of Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) will provide better support for Web 2.0 technologies like REST, POX, ATOM.

·         Performance and Scalability of WCF and WF are expected to increase by minimum 10X.

·         New workflow models.

·         Seamless integration between WCF and WF including a new Visual Designer.

·         Parallel Programming framework using PLINQ, Task Parallel Library and Coordination Data Structures to better utilize power of multi-processor and multi-core machines.

·         Build declarative applications with WF, WCF and WPF using XAML. So, XAML is no more only for WPF and WF.

·         WCF enhancements :

o    RESTful enhancements

§  Simplifying the building of REST Singleton & Collection Services, ATOM Feed and Publishing Protocol Services, and HTTP Plain XML Services using WCF

§  WCF REST Starter Kit to be released on Codeplex to get early feedback

o    Messaging enhancements

§  Transports - UDP, MQ, Local in-process

§  Protocols - SOAP over UDP, WS-Discovery, WS-BusinessActivity, WS-I BP 1.2

§  Duplex durable messaging

o    Correlation enhancements

§  Content and context driven, One-way support

o    Declarative Workflow Services

§  Seamless integration between WF and WCF and unified XAML model

§  Build entire application in XAML, from presentation to data to services to workflow

·         WF enhancements :

o    Significant improvements in performance and scalability

§  Ten-fold improvement in performance

o    New workflow flow-control models and pre-built activities

§  Flowcharts, rules

§  Expanded built-in activities – PowerShell, database, messaging, etc.

o    Enhancements in workflow modeling

§  Persistence control, transaction flow, compensation support, data binding and scoping

§  Rules composable and seamlessly integrated with workflow engine

o    Updated visual designer

§  Easier to use by end-users

§  Easier to rehost by ISVs

§  Ability to debug XAML