VSCommands 3.0.0.0

July 15th, 2010 by mokosh No comments »

NOTE: VSCommands has moved to a new home at http://vscommands.com, so you may want to update your bookmarks and feeds.

VSCommands 3.0.0.0 has been released yesterday, so let’s have a look at some of new features:

Prevent accidental Drag&Drop in Solution Explorer

How many times did you have to fix you solution after accidentally moving files and folder around in Solution Explorer?
With this new feature you will be asked to confirm item move whenever you Drag&Drop in Solution Explorer

draganddropconfirmation

Prevent accidental linked items delete

By default, Visual Studio won’t ask you for confirmation when deleting linked items in Solution Explorer.
VSCommands works around this limitation and will display a confirmation dialog whenever it happens

deletelinkconfirmation

Create Code Contract

Code Contracts are really great and, with release of .Net 4.0, they continue getting more popular in .Net community.
There are, however, some issues that make it less developer friendly than it really should be.
One of these issues is a way that Code Contracts are implemented on interfaces or abstract classes.

Create Code Contract command helps to accomplish it quickly from editor context menu

createcontract
It will create a new class that implements an interface (or inherits from an abstract class) and decorate it with all necessary attributes

codecontractendresult
Build Output – Custom Colours

Formatting of errors and warnings in Build Output can customized.
This makes them stand out and makes it much easier to read.

buildoutputcoloring

Debug Output – Custom Colours

Same as above, formatting can be customized for exceptions, data binding errors and other notifications in Debug Output.

Search Output – Custom Colours

searchresults

Locate In Solution

Locate In Solution command is now available from tab item context menu

locateontab

as well as from Solution Explorer Toolbar

locatesolutiontoolbar
Collapse All

Also available from Solution Explorer Toolbar is Collapse All command.
That means it really is one click away any time you want it!

collapseallsolutiontoolbar

Cancel Build when first project fails

Another time saver  – current build will stop as soon as first project fails to compile.

cancelbuild

Buy me a coffee to sponsor more posts like this!

Silverlight for Symbian released!

July 7th, 2010 by mokosh No comments »

Finally, after more than two years of waiting Silverlight for Symbian has been released.
It works with Nokia S60 5th edition phones (5800, N97) which translates ~ 20 million users.

Silverlight Runtime can be downloaded from Nokia Ovi Store and developer tools from microsoft.com.

Buy me a coffee to sponsor more posts like this!

PRO: .Net 4 Windows Developer (70-518) Exam Passed!

June 30th, 2010 by mokosh 1 comment »

More .net 4 beta exams results have been released today and I’m happy to say that I passed 70-518 – PRO: Designing and Developing Windows Applications Using Microsoft .NET Framework 4.0 exam. The exam covered many aspects of layered design, test and deployment strategies and loosely coupled architecture. It also included one or two questions on Microsoft Sync Framework but I’m not sure if these will be part of the final exam.
Anyways, it’s time for me to celebrate so I’ll be in a pub if anyone needs me ; )

Buy me a coffee to sponsor more posts like this!

VSCommands 2.5.0.0

June 27th, 2010 by mokosh No comments »

VSCommands 2.5.0.0 is ready!
Download it now from Visual Studio Gallery!

New in this version:

 

Collapse All on Solution Folders

image

Locate Source File

Use this command to locate a source of a link item in Solution Explorer (assuming that the source file is a part of the solution)
image

Other Settings

There are several Windows Registry settings that are particularly useful to developers such as forcing IE8 to use only one process (great for Silverlight debugging) or enabling Fusion logs.
VSCommands adds ability to modify these settings easily via options in Visual Studio (because no one likes to fiddle with regedit..) with links to msdn explaining what they do as a bonus.

image 

Other minor bug fixes

Buy me a coffee to sponsor more posts like this!

.Net 4 – Code Contracts and Iterators

June 26th, 2010 by mokosh 1 comment »

Being big fan of Code Contracts I was delighted to learn that they’ve been added as part of .Net 4 and Silverlight 4 frameworks.
Not only this, but also that new release adds extra support for Iterators! Read on to find out more.

Code Contracts and Iterators in the past
There are two main problems with code contracts and iterators: delayed execution and the fact that compiler translates iterator method into a nested class.

Delayed execution means that the code inside iterator method won’t execute until we start iterating through the results.

In a simplified example below, calling TreeTraversal method with a null parameter *won’t trigger a null check*. We have to call IEnumerator.MoveNext() method on a results for the check to be executed (in this example IEnumerator.MoveNext() will be called from .ToList() method).image

Iterator method body after compilation (null check has been moved to the nested class)

image 

Compiler-generated nested class
image

Probably the most widely used workaround for delayed parameter check problem is to create iterator in an internal method and call it from a public method where all the checks are done

image

Not a very pretty solution but it works.

Code Contracts and Iterators in .Net 4

With a .Net 4 release, Code Contracts now support iterators (partially, because post conditions (i.e. Contract.Ensure) are not supported by static checker) and old workarounds are no longer needed.

Going back to our example we can now write following code

imageimage
Notice how *preconditions are checked as soon as iterator method is called*, even before the call to IEnumerator.MoveNext().

Code Contracts and FatalExecutionEngineError was detected

Unfortunately it seems that Code Contracts rewriter doesn’t handle all iterators properly.
In fact, code used in examples above won’t work at all because of FatalExecutionEngineError exception being thrown as soon as iterator method is called.

The runtime has encountered a fatal error. The address of the error was at 0×00000000, on thread 0×11cc. The Error code is 0×80131542. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

image

Now I’m not sure what’s causing this error, but it seems that using for loop instead of nested foreach loops fixes it (this or commenting out Contract.Requires ;) )

image

Looking at the code in reflector we can see the differences in generated code

[FatalExecutionEngineError]

image

image

 

[ Working Code ]

image

image

Clearly Code Contract rewriter has skipped this iterator method completely.
Nevertheless it’s great to have contracts as part of .Net Framework and with better support for Iterators.

Buy me a coffee to sponsor more posts like this!

VS2010 – Problem with assembly signing – Cannot import the following key file xxx.pfx

June 24th, 2010 by mokosh No comments »

Few weeks ago I blogged about a problem with assembly signing in Visual Studio 2010 and how to fix it by using signtool.exe or simply retyping the password.
Today, after Windows 7 installed latest updates, I encountered yet another problem with signing:

Error    22    Cannot import the following key file: xxx.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_xxxxxxxxxxxxxxxx

This time error is different and so is the fix.

First, open VS Command prompt as administrator, then type this command to install key into a key container (use the name of a container from error message)

sn -i <your path>\xxx.pfx VS_KEY_XXXXXXXXXXXXXXXXX

If at this point you get an error message saying that object already exists, then try to delete the container first and type the command again

sn –d VS_KEY_XXXXXXXXXXXXXXXXX

sn -i <your path>\xxx.pfx VS_KEY_XXXXXXXXXXXXXXXXX

Buy me a coffee to sponsor more posts like this!

Windows Applications (70-511) Exam Passed

June 24th, 2010 by mokosh No comments »

MCTS(rgb)_1369_1098_1102

I took the 70-511 beta exam two months ago and just noticed that guys at Microsoft have released the results, so if you took any of the betas recently it might be worth checking your transcript at mcp.microsoft.com.
The biggest difference between new 70-511 Windows Applications and old 70-502 WPF exam is that the new one includes some questions related to WinForms development and, as far as I understand, you don’t need to pass 70-536 (Application Development Foundation) anymore to be awarded Technology Specialist credential. Final version of this exam will be published on 2nd July so check here for more details if you’re interested.

Buy me a coffee to sponsor more posts like this!

VSCommands 2.4.0.0

June 11th, 2010 by mokosh No comments »

VSCommands 2.4.0.0 is ready!
Download it now from Visual Studio Gallery!

New in this version:

 

Thumbnails in IDE Navigator (Ctrl + Tab)

After you install VSCommands it will automatically enable Thumbnails in IDE Navigator (when you navigate between files using Ctrl + Tab)

image

Note that to see thumbnails you may also need to Enable rich client visual experience from Visual Studio –> Tools –> Options –> Environment
(required on lower spec machines or when working on hyper-v/virtual pc)

image

Better Visual Studio Integration

Locate In Solution and Search Online features now work with xaml, aspx, css, js and html files.

 image

Copy Full Path, Open Command Prompt and Paste Link now work with Folders.

image

Zooming

Zooming with Ctrl+Mouse Wheel can be disabled from options and, when enabled, zoom will follow mouse cursor (instead of zooming from the top of document and pushing text down)

image

Other minor bug fixes

Buy me a coffee to sponsor more posts like this!

VS2010 – Problem with assembly signing – An attempt was made to reference a token that does not exist

June 11th, 2010 by mokosh 1 comment »

Visual Studio 2010 seems to have strange problems with assembly signing where one day it works, the other it doesn’t..
When it fails it gives rather cryptic error message:

An attempt was made to reference a token that does not exist

image

 

I’m not sure what the exact cause of error is (vs seems to lose password?), but I’m aware of two possible ways around it:

  • use a signtool.exe in a post build event action to the build process (signtool.exe /f <name>.pfx /p <password> <targetFile>.dll)
  • or in project properties –> signing click Change Password… and enter same old password in both New and Old Password fields.

Buy me a coffee to sponsor more posts like this!

WCF – service require ‘Anonymous’ Authentication but it is not enabled for the IIS application

June 9th, 2010 by mokosh No comments »

I was trying to deploy a Wcf service on IIS the other day and got this error:

Security settings for this service require ‘Anonymous’ Authentication but it is not enabled for the IIS application that hosts this service.

The description was quite confusing because my service was configured to use Windows authentication so Anonymous shouldn’t be needed, right?
Well it turns out that it is still needed if you’re exposing any mex endpoints since they need anonymous authentication.
image

 

The problem will go away if you’ll enable anonymous authentication on IIS or remove mex endpoint from configuration.

 

image

Buy me a coffee to sponsor more posts like this!