Archive for category Visual Studio

Azure Development Fabric and Visual Studio 2010

Just installed Visual Studio 2010. The first thing I tried was creating an new Cloud project.

image

The whole process was surprisingly painless. After creating the solution, I was prompted to download and install the Azure tools. Once they were installed, I deleted and recreated the solution and was prompted for which Roles I wanted:

image

After creating the solution just hit F5 to see the project running in the Azure Development Fabric.

image

The debugger is already connected and all works just as you would expect.

, , , , , ,

No Comments

Run this program as program as an administrator

Vista will try and run most programs without admin rights even if you are signed on as an admin. Some programs such as Visual Studio need admin rights so it is worth setting them to always run as administrator.

Confusingly, looking at a shortcut’s properties, the compatibility tab has an option to “Run this program as an administrator”. This option is greyed out:

Shortcut Compatibility Tab

To set the shortcut to run as administrator go to the shortcut tab > click on Advanced… > check Run as administrator:

Shortcut Advanced Properties

 

No Comments

How to Use InternalsVisibleTo

VS2005 defaults new classes to internal rather than public (although it appears that Orcas defaults to public). This is good as it reduces the public interface of your assembly and it encourages you to actually think about whether a class needs to be public.

You can allow other assemblies access to your internal types and members though, by using the InternalsVisibleTo attribute. This is especially useful for allowing your test assembly to access your internal classes.

This attribute can only be applied to strongly named assemblies.

[assembly:InternalsVisibleTo("TestAssembly, PublicKey=TestAssembly’s public key")]

The attribute requires the assembly name and the public key. To retrieve the public key use sn.exe. Open a visual studio command prompt and enter:

sn.exe -Tp AssemblyPath

Alternatively if you use an alternate file explorer you could set up a macro.

1 Comment

How to Give an Assembly a Strong Name

To Strongly name an assembly you need to associate it with a public and private key. This can be either done by the developer when they compile the assembly (signing) or by at a later stage for instance by the QA department (delayed signing).

Public and private keys can be associated with code signing certificates, generated using sn.exe, or they can be generated from within Visual Studio.

Open the project properties for the assembly you want to sign and check ‘sign the assembly’ on the signing tab. To create a key file, select New from the drop down and follow the directions or Browse for an existing key file. If you create a key file it is worth moving it from the bin directory as you should be using it across multiple projects.

Once compiled you will have a signed assembly with a strong name.

No Comments