Getting the CRM Developer toolkit working with Visual Studio 2013

Yesterday I wrote Where is the CRM Developer toolkit for CRM 2015? and for the past couple of nights I have been wrestling with Visual Studio Community 2013 and the CRM Developer toolkit trying to get them to place nicely with each other.

Visual Studio Community 2013 is awesome

It’s a Windows 8 laptop and thought I would install the Visual Studio Community 2013 edition of Visual Studio.  So far it’s awesome and means I can have a fully working copy of Visual studio on home computer (which is good and a bit sad at the same time :-))

Microsoft have been awesome and the Visual Studio Community 2013 is a free to individual developers, download and see what’s there in the link below

https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx

The page answers a good question, which I have copied below

Q: Who can use Visual Studio Community?
A: Here’s how individual developers can use Visual Studio Community:
  • Any individual developer can use Visual Studio Community to create their own free or paid apps.
Here’s how Visual Studio Community can be used in organizations:
  • An unlimited number of users within an organization can use Visual Studio Community for the following scenarios: in a classroom learning environment, for academic research, or for contributing to open source projects.
  • For all other usage scenarios: In non-enterprise organizations, up to 5 users can use Visual Studio Community. In enterprise organizations (meaning those with >250 PCs or > $1 Million US Dollars in annual revenue), no use is permitted beyond the open source, academic research, and classroom learning environment scenarios described above.

For more information, please refer to the Visual Studio Community 2013 License Terms and the Visual Studio Licensing Whitepaper.

Q: How does Visual Studio Community 2013 compare to other Visual Studio editions?
A: Visual Studio Community 2013 includes all the great functionality of Visual Studio Professional 2013, designed and optimized for individual developers, students, open source contributors, and small teams.

 

Getting the CRM Developer toolkit working

I had avoided the pain of hacking, nudging, shouting and in the end forcing Visual Studio 2013 to work with the CRM developer toolkit.  I had read about it and it didn’t sound like fun.

It has taken a few hours of getting it to work and has taken a lot of mucking about (technical term).

I thought I would blog down my experiences to help other CRM developers who have to go through this.

The main instructions are in this great blog post from Simon Jenkinson, it’s fortunate he blogged this because the initial blog Hashtagcrm.com no longer works 😦

Microsoft Dynamics CRM 2013 Toolkit with Visual Studio 2013

These are the instructions I have copied from the blog above

The first step is to extract the MSI installer file and modify the VSXI Manifest file

1.       Extract the contents of CrmDeveloperToolsVS12_Installer.msi

2.       Open a Command Prompt

3.       Navigate to the extracted SDK folder e.g. C:\CRM-SDK\sdk\Tools\DeveloperToolkit\

4.       Execute the command msiexec /a  C:\CRM-SDK\sdk\tools\DeveloperToolkit\sdkCrmDeveloperToolsVS12_Installer.msi /qb TARGETDIR=C:\CRM-SDK\Toolkit

5.       Navigate to the folder which you extracted the files

6.       Open the Visual Studio folder

7.       Open the archive file Microsoft.CrmDeveloperTools.vsix, or extract it to a sensible location

8.       Then we need to edit the extension.vsixmanifest, and replace – InstalledByMsi=”true” with InstalledByMsi=”false”

9.       We also need to replace all instances of – Version=”[11.0,12.0)” with: Version=”[11.0,12.0]“  (notice the closing bracket has been changed from ) to ] )

10.   Update the manifest file in the archive or repackage the extracted directory.

The instructions work but there is a couple of tricky bits

Step 4 – Tricky bit

Execute the command msiexec /a  C:\CRM-SDK\sdk\tools\DeveloperToolkit\sdkCrmDeveloperToolsVS12_Installer.msi /qb TARGETDIR=C:\CRM-SDK\Toolkit

You have to make sure the target directory already exists or it won’t work, this stopped me for a while because the error message doesn’t say much.

Step 7 – Tricky bit

Step 7 – Open the archive file Microsoft.CrmDeveloperTools.vsix, or extract it to a sensible location

I could get this to work for quite a while.  The main problem I had was if I extracted the Microsoft.CrmDeveloperTools.vsix, this created a folder Microsoft.CrmDeveloperTools, I then edited extension.vsixmanifest to change the ) to ] and change InstalledByMsi=”false” but then I couldn’t figure out how to re-zip or get it back to being the vsix.

In the end I found the solution was to edit the files inside the files inside the Microsoft.CrmDeveloperTools.vsix.

I will admit I didn’t really know what a vsix file was

What is a VSIX?

The VSIX file is the unit of deployment for a Visual Studio 2010 Extension. Visual Studio will recognize the VSIX extension and install the contents of the file to the right location.
A VSIX file is a zip file that uses the Open Packaging Convention. You can rename the .VSIX extension to .ZIP and use any zip browser (including the Windows File Explorer) to browse its contents.

 

So it’s basically a zip file which holds visual studio extensions, this is good because it means you can edit the contents like this and I guess you could re zip them and then rename to VSIX but I found editing inside the vsix easier.

Open file

edit extension

Once you have changed the values you should be able to double click the VSIX and it will install.

The next stage was to copy the folder CRM MSBuild which has the files below in

  • Microsoft.Crm.Sdk.Proxy.dll
  • Microsoft.CrmDeveloperTools.12.targets
  • Microsoft.CrmDeveloperTools.dll
  • microsoft.xrm.sdk.workflow.dll

I had to copy this folder to this directory and rename CRM MSBUILD to CRM

C:\Program Files (x86)\MSBuild\Microsoft

so you should have this

C:\Program Files (x86)\MSBuild\Microsoft\CRM

In this folder you should have the four files mentioned above.

The last tricky part was changing some reg files, I had some problems with this and it turned out I needed the line

Windows Registry Editor Version 5.00

at the top of the reg file edits, who knew.  The text are in the link below

http://pastebin.com/kYjj9XLg

I did have to install Windows Identity Foundation or rather you enable it in Windows 8, instructions here 

It certainly wasn’t straight forward getting this working.  I am really grateful for Simon to blogging about it and giving some clear instructions and I hope this blog augments those to help people get over a few tricky humps.

Advertisement

Visual Studio 2012 keeps crashing

Visual studio has kept crashing for 3 developers over the last few weeks.

What makes it worse is there doesn’t seem to be any consistency to the cause of the crashing, it sneaks up suddenly and POW, freezes and crashes before kindly offering to reopen for you.

What made it more confusing/annoying was no could reproduce the crashing constantly, some days you would have a few days without crashing and then one day it could crash 10 times and ruin your day.

 

We found a solution which seems to work

(backup first) – ALWAYS

then delete the ComponentModelCache folder, which you should find here

C:\Users\xxx\AppData\Local\Microsoft\VisualStudio\11.0\ComponentModelCache

 

The solution doesn’t seem to shed much light on what was causing the crashing, particularly the fact it was happening to different developers on different computers.

 

 

WCF with no service xml or endpoints? What is this magic?

I had to write a WCF service for a project and I hadn’t created a WCF service for a while.

I was trying to write mine to fit in with the rest of the projects but I was totally confused because I was looking at the other WCF services in the project and looking to copy the shell and modify (like all good developers do:-))

I could see there was a SVC file, I could see the code but in the web.config there was no service xml section for the WCF service.

I trying to look at the url for the SVC to see if I could see the wsdl but when I did I got the message no endpoint found.

no endpoint found

 

WHAT WAS GOING ON.

Sometimes as a developer, when you haven’t worked on an area for a while, you have a horrible feeling they have changed the way it worked to some completely new method and framework a bit like the way web services were replaced with WCF.   but this wasn’t the case, it was CRM 2011 project (not that makes any difference calling a WCF service).

The most puzzling aspect was the WCF code was being called (I called it myself to make sure it worked) from a Javascript form.

I asked a developer and he said it must be a factory service, I must have had a completely blank look on my face because he then offered to show me.  A good tip is if you don’t understand something ask someone to point you in the right direction because you can save yourself days of puzzling.

He said right click on the SVC file in Visual Studio and choose View Markup
 
You will see this
mine was like this
<%@ ServiceHost Language=”C#” Debug =”true” Service=”Hosk.HoskRibbonService” CodeBehind=”HoskRibbonService.svc.cs %>
he said change it to this
<%@ ServiceHost Language=”C#” Debug =”true” Service=”Hosk.HoskRibbonService”  Factory=”System.ServiceModel.Activation.WebServiceHostFactory” %>

I removed the service xml section in the web.config and then as if by magic it worked and I was able to call the wcf service using jsonp call (cross domain) in javascript.

Not only had I never heard of using WebServiceHostFactory to create a WCF but I had never come across it in any of the code I have worked with.

I was interested to learn a bit more about it,  It’s a way to dynamically create services and it automatically creates the endpoints for the service and was added in .NET 3.5

 

Here is MSDN class

http://msdn.microsoft.com/en-us/library/system.servicemodel.activation.webservicehostfactory(v=vs.110).aspx

 

this flashcard gives a good quick explanation

http://www.brainthud.com/cards/5218/25206/what-is-the-purpose-of-the-webservicehostfactory-class-and-how-is-it-used

Question

What is the purpose of the WebServiceHostFactory class and how is it used?
Answer

When hosting a web service in IIS, the WebServiceHostFactory class can be used to automatically configure the endpoints for the service. Endpoints will be configured to use WebHttpBinding and WebHttpBehavior. The WebServiceHostFactory class will automatically create a WebServiceHost class when the web service is activated. The following example demonstrates how to reference the WebServiceHostFactory in a .svc file:

<%@ ServiceHost 
    Service="OrderService" 
    Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>

 

 

Here are some simple tutorials if you want to learn more

http://dotnet.dzone.com/articles/creating-restful-wcf-service

http://agilewarrior.wordpress.com/2010/12/19/how-to-create-a-simple-wcf-rest-service/

http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/rest-eanbaled-service-in-wcf-tutorial/

 

Picture from http://daarken.com/blog/2012/08/11/lotr-magic-and-other-news/

Gotcha – Visual Studio must be run as Administrator in windows 7

This has caught me out a few times.  The first time you experience the problem you will notice that the application which was working fine before suddenly is starting to throw unusual errors when you try to run/debug it.

Windows 7 has an annoying feature where you have to specify applications to run as Administrator.  You can set application to always run as Administrator if you go edit the properties of the shortcut or the exe itself and then go to Advanced and select Run as Administrator.

This is fine if you open Visual Studio using the direct shortcut to the program but what happens if you open a project file?  What happens if the project file uses the Visual Studio version selector.

Yes you have guessed it, one day the application was working fine when I opened Visual studio 2010 and then selected the project from within there.

the next day I was getting unusual errors and after debugging for ages I found that it was because I had opened the project directly, which used the visual studio version program which then choose Visual Studio 2010 but it didn’t run it as Administrator.

I tried changing the properties of Visual Studio program Version Selector but it then wouldn’t open the project at all.

So my advice is when you open any projects or sln files in Visual Studio 2010 on windows 7, open Visual Studio first and then select the project.

Exam 70-515 – Ramp up course – Web Development with ASP.NET

Whilst I am studying for the 70-515 Web applications .NET 4 exam, I am always on the lookout for some good information resources.

I have used the ramp up courses from Microsoft before and found them very useful.  They seem to be written from a developers point of view and they give you enough information so you can start developing with the technology and do all the basics.  They give you a sound footing and our a good spring board for you to use

so Today I found a good ramp up course – Ramp up course – Web Development with ASP.NET

It won’t help you with lots of areas on the exam but the information on state management, controls, configuration files are certainly covered in the exam

Learning Resources

Published on: 5/11/2009

 

Number 1 image

An introduction to web programming
We’ll start with how web pages are rendered from a web server, and touch on many of the basic concepts around web development, like HTML, HTTP, XML, and how everything fits together.

 

 

Number 3 image

ASP.NET Syntax Overview
In this module, we will introduce ASP.NET syntax, going step by step through the most common ASP.NET keywords and types you will need to get started building web pages.

 

Number 4 image

Programming WebForms
In this module, we’ll introduce the concept of Web Forms, and how you can use them to group controls as you build your web site.

 

Number 5 image

Web Configuration
Many web sites benefit from settings that span multiple pages within the site. This module will introduce web configuration files, which are a great way to store this type of information.

 

Number 6 image

Programming Web Events
Web events are a way to notify your application when some specific item of interest occurs in your web application. This topic will introduce how you can use web events to make your ASP.NET applications more responsive.

 

Number 7 image

State Management
As visitors move through your web application, it often makes sense to track data on the server, so the application can quickly access information to give the user a better experience. This module will discuss various aspects of state management, and optimal times to choose each technique.

 

Toolbox is missing in visual studio 2010

I was studying for .NET 4 exam and running through one of the lab sessions and it needed me to add a button and dropdown box but then suddenly the toolbox was not coming up.

I was searching around and couldn’t find out how to add it back in, I also couldn’t understand where it would be.

 

Finally I found out how to add the toolbox back in.

 

Go to the VIEW menu

Click on Toolbox

then once again you can enjoy adding buttons and dropdowns to your hearts content

 

Visual Studio 2010 forgets references when building

Wow, this was really driving me nuts.

I added in my CRM references, then when tried to build the solution I got errors complaining it couldn’t find the references to CRM.

AGHGHGHGGHGHGHGHGHGGHGH

Finally I found out what was causing the problem

I had to go into project propertise and then change the target framework from

“.NET Framework 4 Client Profile”

to

“.NET Framework4”

I finally found the answer here

WHY WHY WHY WHY

Where has the Add Web Reference button gone in Visual Studio 2010

I was trying to add a web reference in visual studio 2010 this week and it took me a while to find out where Microsoft had hidden the functionality.

Microsoft always have to hide/rename things whenever they do an upgrade.

Instead of web references all I could find was the Add Service, which means going through the hell of trying to set up a WCF connection.  I’m sure WCF is really deep down very good but every time I have had to use it, I have always had connection/setup issues.

Anyway way back to Web References, which if you are using some legacy code then you might well need to use.  I tried adding a the Web Reference url with a ?wsdl on the end but this didn’t return me a normal web reference and it didn’t work in the same way, which basically meant the old code I had wouldn’t work.  So I had to find out how to add a Web Reference.

So go the references folder in Visual studio 2010,

right click and choose Add Service Reference

press the Advanced Button at the bottom left

Now you can finally add in a good old fashioned Web Reference by bashing on the Add Web Reference Button


 

I borrowed the image from this blog, who also had the same issue.