Web Resource Utility and CRM with Office 365

Posted: Wednesday, 17 July 2013 00:00 CEST in

If you wish to use the Web Resource Utility that comes with CRM 2011 SDK on an CRM Online organization from Office 365, you will not be able to connect to the discovery service.

When you type in your credentials and server address you will get the error message shown below.

Error message

This is because the Web Resource Utility uses

https://dev.[address_typed_in]/XRMServices/2011/Discovery.svc

That is correct for CRM Online as the discovery service, but not when you have CRM from Office 365. Office 365 instances of CRM uses disco insted of dev in the URL. So a correct URL for a CRM Online from Office 365 is

https://disco.[address_typed_in]/XRMServices/2011/Discovery.svc

For more info on the differnet discovery services see MSDN

Luckily there is an easy fix to the problem. In the method GetServerConfiguraton in the class ConsolelessServerConnection we have to change the DiscoveryUri.

Open the file and simply change the line

config.DiscoveryUri = new Uri(String.Format("https://dev.{0}/XRMServices/2011/Discovery.svc", config.ServerAddress));

to

config.DiscoveryUri = new Uri(String.Format("https://{0}/XRMServices/2011/Discovery.svc", config.ServerAddress));

After this change you will have to specify dev/disco part to use the tool, but it will work for both “regular” CRM Online and CRM Online from Office 365.

Connection window


How to install packages when NuGet is down

Posted: Saturday, 17 March 2012 22:33 CET in

Sometime during the 9th of March NuGet.org went down. This turned out to last for a while and a lot of people on twitter told their stories how builds were breaking and how they did not get to download packages. For me, I actually noticed how often I use NuGet and how annoying it is not having a backup plan.

If you wonder why NuGet was down, you can read about it on their blog

Thru twitter I soon realized that I could add my NuGet cache as package feed, this was a great way to use all the packages I usually add to my projects. Unfortunately I had not used the package I needed on that computer before, so I was not able to install the package. But nevertheless I will let you know how you add your NuGet cache as a package feed.

Package manager

It is a pretty easy job to add new feeds to your NuGet package manager console. When you are in the package manager console, click on the “Package Manager Settings” button, marked with red circle in this picture. There is also possible to go on visual studio tools menu and options. Here you find a “Package Manager” node witch is the same place this button goes to or you can go on the tools menu – Library Package Manager – Package Manager Settings.

On the Package Manager Settings page, go to the Package Sources node. Her you see the feeds available to use thru NuGet. Now I am adding a new feed called Local NuGet Cache, and in the source I use C:\Users<LoggedOnUser>\AppData\Local\NuGet\Cache which points to my NuGet cache.

Package manager settings

Now I have this Local NuGet Cache that I created as a option in my Package Manager Console and can use it just as I would use the official NuGet feed.

Package manager feeds

So my backup strategy now is that I put my Local NuGet Cache and my public MyGet feed as alternative feeds in Visual Studio. So if NuGet will go down again for any reason I have some chances to get my most used packages still. If it is a package I have used on that particular computer before, it will be in my local NuGet cache. If it is not a package I have used before, hopefully I have added it to my MyGet feed so it is still available to me.

If you wonder what www.myget.org is, it is a site where you can create your own NuGet feed with packages from NuGet or any other package you might have. It is easy to use, works great and it is free if you choose the public or community feed, private feeds are not free.


.Net Client profile annoyance, and how to get rid of it

Posted: Sunday, 13 November 2011 13:20 CET in

In Visual Studio 2010 some project types(MSDN for full list) defaults to .Net Framework 4 Client Profile. In many cases that is a problem, actually in my line of work it is always a problem. The problem for me is that I reference libraries that target the full .Net framework, not the subset framework .Net client profile.

So when I add a reference to structuremap or any other library which targets the full .Net framework, everything looks good until the project is being build. Then I get an error: “The type or namespace name ‘StructureMap’ could not be found (are you missing a using directive or an assembly reference?)”.

Target framework The first few times I got this error message I wasted quite some time on troubleshooting. Now it is just annoying and I immediately change the target framework when I get this error message. You can change the target framework in the properties of your project. Just right-click project and choose properties.

On the new project screen in Visual Studio, there is a dropdown menu where it is possible to choose the target framework. But this list only show the full frameworks. Unfortunately there is no setting in Visual Studio to set projects to use the full framework either. But there is an solution, change the project template. New project screen

The project templates for C# in an default installation can be found “\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates\CSharp”. In this example I will change the Console application. So from the CSharp directory I browse my way to “Windows\1033". Here are all the project templates that is available for windows applications in C#.

I copy the ConsoleApplication.zip file to some other location, so I got a backup of the project template.

Back in the project templates folder, I unzip the ConsoleApplication.zip and then open consoleapplication.csproj in some text editor. In this file I remove line 14 to 16. See the lines I remove below.

$if$ ($targetframeworkversion$ >= 4.0)
   <TargetFrameworkProfile>Client</TargetFrameworkProfile>
$endif$

Then I save the file and zip the files back to a zip file I call ConsoleApplication.zip. The project template is now done, but there is still one small thing left to do.

Since Visual Studio cache the project templates, a new project of type console application would now still be using the .Net 4 Client Profile framework. So we will have to update the cached folder. The cached folder is located “\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplatesCache\CSharp\Windows\1033” if you wondered. To update the cached folder I launch the Visual Studio Command Prompt and run the command “devenv /installvstemplates”. This command runs for some seconds. When it is finished without any errors you can launch Visual Studio and create a console application project. Now it uses the full .Net 4 Framework, not the .Net 4 Client Profile.


LINQ to Sql with schema name other than dbo

Posted: Sunday, 04 September 2011 22:03 CEST in

At my former employer we were working with an CRM system from Visma. Visma is an Norwegian software company creating CRM, ERP and a lot of other systems. In this CRM system you could have several clients/companies and you would choose what client you want to logon to at startup.

When a new client were created, it would create an database with the same name as the client and a user in the sql server. All the objects in the created database would also use the schema of the created login, not the dbo schema.

This is causing some problems when using Linq to sql, because when an dbml file is created it uses the schema from the tables that is selected in the model. So when we created a model for client1 in an application, this application would not run against client2. Because in the dbml file every table is saved with the schema for client1, and in client2 the schema name is client2.

Luckily an co-worker found a great blog post from Guy Barrette that describes a way to create an mapping file so we could use our application on all the clients we’d like.

Guy’s blog post


dotPeek–Free .Net decompiler

Posted: Friday, 19 August 2011 22:23 CEST in

Ever wondered what the .Net framework looked like or had the need to look into someone else’s code? Then dotPeek from Jetbrains is the thing for you.

dotPeek decompiles any .Net assembly, from the old 1.0 to 4.0. The decompiled assembly is categorized in namespaces and all the code is shown in C#. You can browse your hard drives for assemblies to look at or have a look at those in the GAC.

Easy navigating, familiar shortcut keys and syntax highlighting that all remind you of Visual Studio.

There are others decompilers for .Net as well, IL Disassembler comes with the .Net SDK, but it only show you the IL code as the name suggests. Another one and probably the most known decompiler is .Net Reflector from Redgate. Its not free, but the professional editions come with Visual Studio integration, possibility to debug assemblies you don’t even have the source code too and much more. There is also a bunch of other decompilers out there, but I don’t have any experience with any other then the three that I have mentioned.

For me it is not very often I have the use for a decompiler, but when there is a situation you need too look into an assembly you don’t have the source code too, they are great. I had one of those moments this week and dotPeek came along and saved the day. Thank you =)


About Sebastian

Sebastian Holager

Sebastian Holager is a developer working in Oslo, Norway. At day time hacking away on Dynamcs CRM, C# and JavaScript. While at night playing around with other programming languages, reading and watching football.

Follow me on twitter