Posts Tagged Visual Studio

Macs, Parallels and Keyboard Layouts

I am currently developing on a Mac, running Visual Studio on a Windows 7 VM courtesy of Parallels. There are a number of issues to resolve the first of which is the key mappings.

I am using the Mac bluetooth keyboard and a few keys are mapped incorrectly:

Pressing this key Results in this output
§ `
± ¬
@
@
\ #
| ~

When using OS X alt + 3 produces a # and alt + 2 produces a €. Unfortunately in Windows alt key combinations are normally used to launch menu items.

The answer to this is a free program from Microsoft called Keyboard Layout Creator.

Download and install this (on your Windows VM) then you can use it to create a correct layout. Once you have the layout you can create an installer to install your keyboard layout on however many VMs you like.

You can download the layout I created and open the file in the layout creator to build your own installer. I have also uploaded the installer I created (mostly for my own reference, I make no guarantees it will not fry your system, please use a good virus scanner etc.).

Once you have installed the layout open Keyboards and languages:

image

Then change the default input language and keyboard:

image

Any applications that are open need to be restarted, but then you should have all keys working correctly.

I have mapped # to Ctrl + alt + 3 and € to ctrl + alt + 2 which should work as long as the application you are in is not using them as shortcut keys.

, , , , , , , , , , , , , , , , , , ,

No Comments

DI with Ninject for an MVC project

This seems to be a somewhat moving target with ASP.Net MVC moving up the versions as well as Ninject. This particular target will be ASP.Net MVC 2.0 and Ninject 2.0.

First set up the references:

  1. Download Ninject.Web.Mvc (If not using git, there is a download source link on the page).
  2. Open the mvc2/Ninject.Web.Mvc.sln and compile with release settings.
  3. Copy the files Ninject.dll and Ninject.Web.Mvc.dll from the mvc2/build/debug/release folder to the lib folder of your MVC project.
  4. Add references to these two files to your MVC project.

The DI Container (called a Kernel with Ninject) needs initializing on app startup which, with MVC, is in the Global.asax. Add the following using statements to the Global.asax:

using Ninject;
using Ninject.Modules;
using Ninject.Web.Mvc;

Change the MvcApplication so it inherits from NinjectHttpApplication:

public class MvcApplication : NinjectHttpApplication {

Let Visual Studio implement the CreateKernel method.

override the OnApplicationStarted method copying in the lines from the Application_Start method:

protected override void OnApplicationStarted() {
    AreaRegistration.RegisterAllAreas();
    RouteRegistrar.RegisterRoutes(RouteTable.Routes);
}

Then delete the Application_Start method.

Ninject stores the rules it uses to return class instances in Modules which are derived from NinjectModule. Add the following class to the MVC project:

using Ninject.Modules;

namespace MvcApp.Web {
    public class WebModule : NinjectModule {
        #region Instance Methods

        public override void Load() {
        }

        #endregion
    }
}

The Load method is where we specify how each request for a concrete class is fulfilled.

Lastly, modify the CreateKernel method so that the module is passed into the Kernel’s ctor:

protected override IKernel CreateKernel() {
    var modules = new INinjectModule[]
                      {
                          new WebModule()
                      };
    var kernel = new StandardKernel(modules);
    return kernel;
}

, , , , , , , , , , , , , ,

No Comments

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