Bassetassen blog2021-02-11T16:53:18+01:00http://www.bassetassen.comSebastian Holagerbassetassen@gmail.comSetup TeamCity with HTTPS2018-07-02T23:10:00+02:00http://www.bassetassen.com/2018/07/02/teamcity-with-https-only
<p>At work we have recently moved our CI server and made it available without having to use VPN. As we did this switch we also made it accessible only thru HTTPS. Here are the steps we did to make that work.</p>
<p>First we copied out pfx file to the CI server, then we had to make a few adjustments to some of the config files.</p>
<p>In TeamCity/conf/server.xml we added this element, here you can see the path to the pfx file and the password for the file.</p>
<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><Connector</span> <span class="na">port=</span><span class="s">"443"</span> <span class="na">protocol=</span><span class="s">"org.apache.coyote.http11.Http11NioProtocol"</span>
<span class="na">SSLEnabled=</span><span class="s">"true"</span>
<span class="na">scheme=</span><span class="s">"https"</span>
<span class="na">secure=</span><span class="s">"true"</span>
<span class="na">connectionTimeout=</span><span class="s">"60000"</span>
<span class="na">redirectPort=</span><span class="s">"8543"</span>
<span class="na">clientAuth=</span><span class="s">"false"</span>
<span class="na">sslProtocol=</span><span class="s">"TLS"</span>
<span class="na">useBodyEncodingForURI=</span><span class="s">"true"</span>
<span class="na">keystoreFile=</span><span class="s">"C:\TeamCity\conf\cert.pfx"</span>
<span class="na">keystorePass=</span><span class="s">"password"</span>
<span class="na">socket.txBufSize=</span><span class="s">"64000"</span>
<span class="na">socket.rxBufSize=</span><span class="s">"64000"</span>
<span class="na">tcpNoDelay=</span><span class="s">"1"</span>
<span class="nt">/></span>
</code></pre></div></div>
<p>After a restert of the TeamCity service it is now possible to reach the server on HTTPS.</p>
<p>The next step for us was to force the use of HTTPS, so we had to make a change to TeamCity/conf/web.xml. We added this XML to the file just before the web-app closing tag.</p>
<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code> <span class="nt"><security-constraint></span>
<span class="nt"><web-resource-collection></span>
<span class="nt"><web-resource-name></span>Restricted URLs<span class="nt"></web-resource-name></span>
<span class="nt"><url-pattern></span>/*<span class="nt"></url-pattern></span>
<span class="nt"></web-resource-collection></span>
<span class="nt"><user-data-constraint></span>
<span class="nt"><transport-guarantee></span>CONFIDENTIAL<span class="nt"></transport-guarantee></span>
<span class="nt"></user-data-constraint></span>
<span class="nt"></security-constraint></span>
<span class="nt"></web-app></span>
</code></pre></div></div>
<p>After a restart we can still access TeamCity over HTTPS, but when using HTTP the redirect goes to HTTPS on port 8543. We open up TeamCity/conf/server.xml again and change one line in the HTTP connector. Here we change the redirectPort from 8543 to 443.</p>
<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><Connector</span> <span class="na">port=</span><span class="s">"80"</span> <span class="na">protocol=</span><span class="s">"org.apache.coyote.http11.Http11NioProtocol"</span>
<span class="na">connectionTimeout=</span><span class="s">"60000"</span>
<span class="na">redirectPort=</span><span class="s">"443"</span>
<span class="na">useBodyEncodingForURI=</span><span class="s">"true"</span>
<span class="na">socket.txBufSize=</span><span class="s">"64000"</span>
<span class="na">socket.rxBufSize=</span><span class="s">"64000"</span>
<span class="na">tcpNoDelay=</span><span class="s">"1"</span>
<span class="nt">/></span>
</code></pre></div></div>
<p>After another restart of the TeamCity service all is working as expected and our users is forced over on HTTPS.</p>
Create an entity using the WebApi with lookup values2017-10-27T15:45:00+02:00http://www.bassetassen.com/2017/10/27/create-entity-and-associate-with-webapi
<p>When creating a new entity with the WebApi for Dynamics 365 the documentation looks pretty clear. It also looks straight forward when associating the new entity with an existing one. See <a href="https://msdn.microsoft.com/en-us/library/gg328090.aspx#Anchor_3">here</a> for a reference.</p>
<p>This example from the previous link creates an account and set the primary contact.</p>
<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="s2">"Sample Account"</span><span class="p">,</span><span class="w">
</span><span class="nl">"primarycontactid@odata.bind"</span><span class="p">:</span><span class="s2">"/contacts(e13072b3-81ba-e711-8108-5065f38ba391)"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>
<p>When looking at the code one would think that it is the logicalname for the attribute that is in use here and we only need to append the @odata.bind part. But as soon we start to associate custom entities we will see that it is not the logicalname of the attribute but rather the associatednavigationproperty.</p>
<p>Here is the result querying the newly created account with prefer header set to odata.include-annotations=”*”</p>
<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
</span><span class="nl">"@odata.context"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://someorg.api.crm4.dynamics.com/api/data/v8.2/$metadata#accounts(_primarycontactid_value)/$entity"</span><span class="p">,</span><span class="w">
</span><span class="nl">"@odata.etag"</span><span class="p">:</span><span class="w"> </span><span class="s2">"W/</span><span class="se">\"</span><span class="s2">1434863</span><span class="se">\"</span><span class="s2">"</span><span class="p">,</span><span class="w">
</span><span class="nl">"_primarycontactid_value@OData.Community.Display.V1.FormattedValue"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Sebastian Holager"</span><span class="p">,</span><span class="w">
</span><span class="nl">"_primarycontactid_value@Microsoft.Dynamics.CRM.associatednavigationproperty"</span><span class="p">:</span><span class="w"> </span><span class="s2">"primarycontactid"</span><span class="p">,</span><span class="w">
</span><span class="nl">"_primarycontactid_value@Microsoft.Dynamics.CRM.lookuplogicalname"</span><span class="p">:</span><span class="w"> </span><span class="s2">"contact"</span><span class="p">,</span><span class="w">
</span><span class="nl">"_primarycontactid_value"</span><span class="p">:</span><span class="w"> </span><span class="s2">"e13072b3-81ba-e711-8108-5065f38ba391"</span><span class="p">,</span><span class="w">
</span><span class="nl">"accountid"</span><span class="p">:</span><span class="w"> </span><span class="s2">"72bc7a32-82ba-e711-8108-5065f38ba391"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>
<p>When querying with this prefer header we get to see the name of the associatednavigationproperty. In this example it’s not possible to conclude if it is the logicalname or the associatednavigationproperty that is used.</p>
<p>When setting a lookup on a custom attribute the associatednavigationproperty is set to the same as the schemaname, this is confusing because this is not the case on the standard lookup attributes as we saw on the primarycontactid example above. Schemaname for primarycontactid is PrimaryContactId.</p>
<p>Here is a example on a custom entity, notice the case-sensitivity. Here the associatednavigationproperty is equal to the schemaname of the attribute.</p>
<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
</span><span class="nl">"new_Testentitet@odata.bind"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/new_testentitets(0FB7A14C-8DBA-E711-810A-5065F38BD3C1)"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>
<p>Now let’s look at a custom activity, then things really starts to be interesting.</p>
<p>In this example I will create a custom activity. Here is the body of the POST.</p>
<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
</span><span class="nl">"regardingobjectid_incident@odata.bind"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/incidents(5CD45010-6752-E711-80FA-5065F38BA391)"</span><span class="p">,</span><span class="w">
</span><span class="nl">"crmntime_Case_crmntime_TimeEntry@odata.bind"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/incidents(5CD45010-6752-E711-80FA-5065F38BA391)"</span><span class="p">,</span><span class="w">
</span><span class="nl">"crmntime_HourTypeMain_crmntime_TimeEntry@odata.bind"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/crmntime_hourtypes(2b645ea3-7352-e711-80fa-5065f38ba391)"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>
<p>We associate the same incident in the custom crmntime_case attribute and the standard regardingobjectid attribute of an activity. We also associate an crmntime_hourtype that is a custom attribute referencing a custom entity.</p>
<p>This is the result when querying the newly created recored.</p>
<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
</span><span class="nl">"_regardingobjectid_value@OData.Community.Display.V1.FormattedValue"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Test"</span><span class="p">,</span><span class="w">
</span><span class="nl">"_regardingobjectid_value@Microsoft.Dynamics.CRM.associatednavigationproperty"</span><span class="p">:</span><span class="w"> </span><span class="s2">"regardingobjectid_incident_crmntime_timeentry"</span><span class="p">,</span><span class="w">
</span><span class="nl">"_regardingobjectid_value@Microsoft.Dynamics.CRM.lookuplogicalname"</span><span class="p">:</span><span class="w"> </span><span class="s2">"incident"</span><span class="p">,</span><span class="w">
</span><span class="nl">"_regardingobjectid_value"</span><span class="p">:</span><span class="w"> </span><span class="s2">"5cd45010-6752-e711-80fa-5065f38ba391"</span><span class="p">,</span><span class="w">
</span><span class="nl">"_crmntime_case_value@OData.Community.Display.V1.FormattedValue"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Test"</span><span class="p">,</span><span class="w">
</span><span class="nl">"_crmntime_case_value@Microsoft.Dynamics.CRM.associatednavigationproperty"</span><span class="p">:</span><span class="w"> </span><span class="s2">"crmntime_Case_crmntime_TimeEntry"</span><span class="p">,</span><span class="w">
</span><span class="nl">"_crmntime_case_value@Microsoft.Dynamics.CRM.lookuplogicalname"</span><span class="p">:</span><span class="w"> </span><span class="s2">"incident"</span><span class="p">,</span><span class="w">
</span><span class="nl">"_crmntime_case_value"</span><span class="p">:</span><span class="w"> </span><span class="s2">"5cd45010-6752-e711-80fa-5065f38ba391"</span><span class="p">,</span><span class="w">
</span><span class="nl">"_crmntime_hourtypemain_value@OData.Community.Display.V1.FormattedValue"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Test type"</span><span class="p">,</span><span class="w">
</span><span class="nl">"_crmntime_hourtypemain_value@Microsoft.Dynamics.CRM.associatednavigationproperty"</span><span class="p">:</span><span class="w"> </span><span class="s2">"crmntime_HourTypeMain_crmntime_TimeEntry"</span><span class="p">,</span><span class="w">
</span><span class="nl">"_crmntime_hourtypemain_value@Microsoft.Dynamics.CRM.lookuplogicalname"</span><span class="p">:</span><span class="w"> </span><span class="s2">"crmntime_hourtype"</span><span class="p">,</span><span class="w">
</span><span class="nl">"_crmntime_hourtypemain_value"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2b645ea3-7352-e711-80fa-5065f38ba391"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>
<p>When looking at this result we can see that regardingobjectid_incident is not the associatednavigationproperty, but using regardingobjectid_incident_crmntime_timeentry@odata.bind also work.</p>
<p>Notice that the associatednavigationproperty is case-sensitive and on custom relationships on custom activities it looks like it take the form of <em>attribute schema name</em>_<em>entity schema name</em>. In this example for the hourtypemain lookup the attribute schema name is crmntime_HourTypeMain and this lookup attribute exist on enity with schema name crmntime_TimeEntry so the associatednavigationproperty becomes crmntime_HourTypeMain_crmntime_TimeEntry. This is different from other custom lookup attributes on custom entities where the form of associatednavigationproperty is equal to schemaname of the attribute.</p>
<p>I hope these examples can help you out when exploring the Web Api and associating entities when creating and updating entities.</p>
Building C# 7 with TeamCity2017-10-19T14:30:00+02:00http://www.bassetassen.com/2017/10/19/building-csharp7-with-teamcity
<p>We have started using some new language features from C# 7 lately and then some builds on Team City started failing. Luckily I remembered my post from the time we started using C# 6 features. You can find that post <a href="/2015/08/13/building-csharp6-with-teamcity">here</a></p>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="go">error CS1003: Syntax error, ',' expected
</span></code></pre></div></div>
<p>The builds were using the Visual Studio sln build configuration and was set to Visual Studio 2015. I changed this to Visual Studio 2017, but then there was no compatible agent. I then installed the Build Tools for Visual Stuido 2017 and restarted the agents, now everything is working as expected.</p>
<p>You find the Build Tools for Visual Studio 2017 <a href="https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017">here</a>. Scroll all the way to the bottom and you find the download link or just search for Build tools.</p>
Accessing Dynamics 365 from Ubuntu2017-01-22T13:00:00+01:00http://www.bassetassen.com/2017/01/22/accessing-dynamics-365-from-ubuntu
<p>From home when using Dynamics 365 on a Ubuntu machine I’m quite regularly getting the mobile forms when accessing Dynamics 365. So today I wanted to investigate this some more.</p>
<p>I start with Firefox and logged in to http://portal.office.com. When I click on the Dynamics 365 tile, I get an error on the new app page.
<img src="http://www.bassetassen.com/assets/images/dynamics_ubuntu/firefox-portal-error.png" class="img-responsive img-right" alt="Error message when using Firefox" title="Error message when using Firefox" /></p>
<p>When I close this dialog there is a blank page with portal menu on the top. Refreshing the page or pressing the sync button does not help.</p>
<p>I then try to go directly to my instance of Dynamics 365 with the url https://{organization}.crm4.dynamics.com. Then we are logged in to the mobile site.</p>
<p>So no luck with Firefox, let’s try Chrome.</p>
<p>When logging in to the portal with Chrome and clicking on the Dynamics 365 tile there is no error and I can see all my apps. Clicking on one of them I get to my organization.</p>
<p>If I type in the address to the organization as I tried with Firefox, I get the mobile site as I did with Firefox.</p>
<p>So to summarize I have to use Chrome and log in through portal.office.com or home.dynamics.com to avoid getting the mobile site of Dynamics 365 on a Ubuntu machine.</p>
Setting up Pidgin for Skype for business2015-09-27T17:49:00+02:00http://www.bassetassen.com/2015/09/27/pidgin-sipe-skype-for-business
<p>At work we use Skype for business, formerly known as Lync, for IM. That works fine at work where I use a Windows 10 machine. But sometimes I want to use Skype for business to chat with some colleagues from home. So I wanted to get a Skype for business client on my home machine running Ubuntu.</p>
<p>After a little bit of googling I found that there was a plugin for <a href="https://pidgin.im">Pidgin</a> called <a href="http://sipe.sourceforge.net">pidgin-sipe</a>. So I install Pidgin and Pidgin-sipe with apt-get.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>apt-get <span class="nb">install </span>pidgin pidgin-sipe
</code></pre></div></div>
<p>Then I open Pidgin and add an account. On the basic tab I used these settings:</p>
<ul>
<li>Protocol: Office Communicator</li>
<li>Username: My email</li>
<li>Password: My Password</li>
</ul>
<p>On the advanced tab:</p>
<ul>
<li>Connection type: Auto</li>
<li>Authentication scheme: TLS-DSK</li>
</ul>
<p>When I’m connecting now, I get an error, saying unable to validate certificate. To fix this I go to this domain, download the certificate and put it in ~/.purple/certificates/x509/tls_peers/
It seems like it is important to name the certificate file the same as the domain, so I name the certificate file webext01.phonectuc.net
<img src="http://www.bassetassen.com/assets/images/pidgin_sipe_setup/SSL_Certificate_Error.png" class="img-responsive img-right" alt="Messagebox with error" title="Unable to validate certificate" /></p>
<p>Now I get the same error with another domain, I can see in the certificate’s alternative names section in the downloaded certificate, that this domain is listed there. So I only make a copy of the already downloaded certificate and rename it to the domain name.</p>
<p>And now I am able to login and chat with my colleagues. As of this writing I am using Pidgin 2.10.9 and Sipe 1.18.2</p>
Building C# 6 with TeamCity2015-08-13T18:24:00+02:00http://www.bassetassen.com/2015/08/13/building-csharp6-with-teamcity
<p>After we upgraded to Visual Studio 2015 and started to use some of the new language features in C#6, we got some trouble at work with some of our CI builds. We use TeamCity as build server and we had recently updated to 9.1.1. The builds was using the Visual Studio sln build configuration and was set to Visual Studio 2013.</p>
<p>The error was unexpected character ‘$’. So it was easy to understand that it was the new string interpolation that was causing out build to break.</p>
<p><img src="http://www.bassetassen.com/assets/images/building_csharp6_with_teamcity/tc-csharp6-error.png" class="img-responsive img-right" alt="error CS1056: Unexpected character '$'" title="Error message with wrong build configuration" /></p>
<p>The first thing we did was to change the configuration to use Visual Studio 2015, but that only made the build incompatible with all of our build agents.</p>
<p>We then installed the build tools for 2015 and restarted the server. Then the build had compatible agents, and the build worked again. Here is a link to the <a href="http://www.microsoft.com/en-in/download/details.aspx?id=48159">Microsoft Build Tools 2015</a></p>
<p>This was for an internal library that now was working again, but there still was a web project that had problems. This time the build was complaining about some missing files.</p>
<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>C:\TeamCity\BuildAgent\...\Web.csproj(1045, 3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
</code></pre></div></div>
<p>To fix this error, we copied over the files from a computer with Visual Studio 2015 installed to the build server and this build was working again. We actually copied over the whole v14.0 folder.</p>
Bricking your CRM Forms, the ultimate guide2014-10-20T22:22:00+02:00http://www.bassetassen.com/2014/10/20/crm-bricked-forms
<p><img src="http://www.bassetassen.com/assets/images/bricked_crm_forms/loader.png" class="img-responsive img-right" alt="Loader" title="Bricked white windows, never ending loader" /></p>
<p>The other day I completely bricked a form in Dynamics CRM. The form would just have the command bar and loader up, but nothing happen. This was in a custom entity we use for some settings, and I had a text field which was a template text for SMS sending. This text also had a few template codes that could be used. So in an attempt to be helpful. I added the available template codes in the description for the field. This way I thought it was easy for the user generating this templates to see what template codes that is available in the tool tip.</p>
<p>I had chosen a template format like {{contactname}}, and then I would replace this with the name of the contact when we were sending the SMS. The problem is that this is a pretty widely used format, and CRM uses JsRender, which uses this kind of format as well.</p>
<p>It also took some time to figure out what was wrong, because only Internet Explorer showed something in the console. And IE, was sadly in this case, not the first browser I tried. But when I did try IE, it gave me the error message below, and I immediately understood what had gone wrong.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
JsRender Error: Syntax error
Unmatched or missing tag: "{{/contactname}}" in template
</code></pre></div></div>
<p><img src="http://www.bassetassen.com/assets/images/bricked_crm_forms/field_metadata.png" class="img-responsive img-right" alt="Field metadata" title="Description on field, do not put double curly brackets here" /></p>
<p>So by removing these template codes from the description on the field and publishing again everything was working as expected. I tried using HTML escape characters for the curly braces, but they was only showed as they are typed in. So as far as I know, there is no way to show template codes as these ones in the tool tip.</p>
<p>There is no problem storing these kind of templates in the field itself, but do not put it in the description of the field. There is also no problem storing single curly brackets in the description field either, just stay away from the double.</p>
Hiding menu when printing in Dynamics CRM2014-09-18T22:45:00+02:00http://www.bassetassen.com/2014/09/18/hiding-menu-in-print
<p>Recently I had a client requirement that involved printing of CRM pages that contained web resources. The standard print functionality in Dynamics CRM only supports printing static content, so some web resources used on the page being printed was omitted. The user wanted to use the browsers print capabilities and it all worked great, except that the Dynamics CRM header was included on the top.</p>
<p><img src="http://www.bassetassen.com/assets/images/hiding_menu_in_print/print-heading.png" class="img-responsive" alt="Print preview showing CRM menu" title="CRM menu at the top of the page when printing in browser" /></p>
<p>As you can see from the picture above, the menu from CRM on the top of the page, taking up some much needed space from other content.</p>
<p>The solution in our case was to do a little unsupported change by injecting some CSS in the page with JavaScript. You will only see this change when printing because of the media in the CSS is set to print.</p>
<figure class="highlight"><pre><code class="language-javascript" data-lang="javascript"><span class="nx">$</span><span class="p">(</span><span class="dl">'</span><span class="s1">head</span><span class="dl">'</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="dl">'</span><span class="s1"><style>@media print { #crmMasthead, #crmTopBar {display: none !important;} #crmContentPanel {top: 0 !important;}}</style></span><span class="dl">'</span><span class="p">);</span></code></pre></figure>
<p>As you can see below, the menu is now gone and we get some extra space on each page when printing.</p>
<p><img src="http://www.bassetassen.com/assets/images/hiding_menu_in_print/print-heading-removed.png" class="img-responsive" alt="Print preview showing page without CRM menu" title="CRM menu at the top of the page is now gone when printing in browser" /></p>
New blog2014-09-07T23:01:00+02:00http://www.bassetassen.com/2014/09/07/new-blog
<p>I have planned for a long time now to change blog platform, this weekend I finally got around to it. My choice for blog platform is <a href="http://jekyllrb.com/">Jekyll</a> and <a href="http://jekyllbootstrap.com/">Jekyll bootstrap</a>. The blog is now hosted on <a href="https://pages.github.com/">GitHub pages</a>. I have changed the default design form Jekyll bootstrap a bit, but it is still pretty plain and I guess that reflects my design skills :)</p>
<p>Now I just have to start blogging on a more regular basis.</p>
Web Resource Utility and CRM with Office 3652013-07-17T00:00:00+02:00http://www.bassetassen.com/2013/07/17/web-resource-utility-and-crm-with-office-365
<p>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.</p>
<p>When you type in your credentials and server address you will get the error message shown below.</p>
<p><img src="http://www.bassetassen.com/assets/images/webresourceutility_crm365/error_logging_in.png" class="img-responsive" alt="Error message" title="Error message in webresource utility" /></p>
<p>This is because the Web Resource Utility uses</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>https://dev.[address_typed_in]/XRMServices/2011/Discovery.svc
</code></pre></div></div>
<p>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</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>https://disco.[address_typed_in]/XRMServices/2011/Discovery.svc
</code></pre></div></div>
<p>For more info on the differnet discovery services see <a href="http://msdn.microsoft.com/en-us/library/gg328127.aspx">MSDN</a></p>
<p>Luckily there is an easy fix to the problem. In the method GetServerConfiguraton in the class ConsolelessServerConnection we have to change the DiscoveryUri.</p>
<p>Open the file and simply change the line</p>
<figure class="highlight"><pre><code class="language-csharp" data-lang="csharp"><span class="n">config</span><span class="p">.</span><span class="n">DiscoveryUri</span> <span class="p">=</span> <span class="k">new</span> <span class="nf">Uri</span><span class="p">(</span><span class="n">String</span><span class="p">.</span><span class="nf">Format</span><span class="p">(</span><span class="s">"https://dev.{0}/XRMServices/2011/Discovery.svc"</span><span class="p">,</span> <span class="n">config</span><span class="p">.</span><span class="n">ServerAddress</span><span class="p">));</span></code></pre></figure>
<p>to</p>
<figure class="highlight"><pre><code class="language-csharp" data-lang="csharp"><span class="n">config</span><span class="p">.</span><span class="n">DiscoveryUri</span> <span class="p">=</span> <span class="k">new</span> <span class="nf">Uri</span><span class="p">(</span><span class="n">String</span><span class="p">.</span><span class="nf">Format</span><span class="p">(</span><span class="s">"https://{0}/XRMServices/2011/Discovery.svc"</span><span class="p">,</span> <span class="n">config</span><span class="p">.</span><span class="n">ServerAddress</span><span class="p">));</span></code></pre></figure>
<p>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.</p>
<p><img src="http://www.bassetassen.com/assets/images/webresourceutility_crm365/connection.png" class="img-responsive" alt="Connection window" title="This is how you need to type in server address after the change in webresource utility" /></p>
How to install packages when NuGet is down2012-03-17T22:33:00+01:00http://www.bassetassen.com/2012/03/17/how-to-install-packages-when-nuget-is-down
<p>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.</p>
<p>If you wonder why NuGet was down, you can read about it on their <a href="http://blog.nuget.org/20120314/the-nuget-gallery-outage-on-march-9.html">blog</a></p>
<p>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.</p>
<p><img src="http://www.bassetassen.com/assets/images/nuget_down/package_manager_console_settings_button.png" class="img-responsive img-right" alt="Package manager" title="The package manager window" /></p>
<p>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.</p>
<p>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.</p>
<p><img src="http://www.bassetassen.com/assets/images/nuget_down/package_manager_settings_feeds.png" class="img-responsive" alt="Package manager settings" title="The package manager settings window" /></p>
<p>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.</p>
<p><img src="http://www.bassetassen.com/assets/images/nuget_down/package_manager_console_list_feeds.png" class="img-responsive img-right" alt="Package manager feeds" title="Package manager feeds" /></p>
<p>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.</p>
<p>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.</p>
.Net Client profile annoyance, and how to get rid of it2011-11-13T13:20:00+01:00http://www.bassetassen.com/2011/11/13/net-client-profile-annoyance-and-how-to-get-rid-of-it
<p>In Visual Studio 2010 some project types(<a href="http://msdn.microsoft.com/en-us/library/cc656912.aspx">MSDN for full list</a>) 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.</p>
<p>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?)”.</p>
<p><img src="http://www.bassetassen.com/assets/images/client_profile/target_framework.png" class="img-responsive img-right" alt="Target framework" title="The target framework dropdown" />
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.</p>
<p>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.
<img src="http://www.bassetassen.com/assets/images/client_profile/new_project.png" class="img-responsive img-right" alt="New project screen" title="New project screen" /></p>
<p>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#.</p>
<p>I copy the ConsoleApplication.zip file to some other location, so I got a backup of the project template.</p>
<p>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.</p>
<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$if$ ($targetframeworkversion$ >= 4.0)
<span class="nt"><TargetFrameworkProfile></span>Client<span class="nt"></TargetFrameworkProfile></span>
$endif$
</code></pre></div></div>
<p>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.</p>
<p>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.</p>
LINQ to Sql with schema name other than dbo2011-09-04T22:03:00+02:00http://www.bassetassen.com/2011/09/04/linq-to-sql-with-schema-name-other-than-dbo
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p><a href="http://weblogs.asp.net/guybarrette/linq-to-sql-dynamic-mapping">Guy’s blog post</a></p>
dotPeek–Free .Net decompiler2011-08-19T22:23:00+02:00http://www.bassetassen.com/2011/08/19/dotpeek-free-dotnet-decompiler
<p>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.</p>
<p>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.</p>
<p>Easy navigating, familiar shortcut keys and syntax highlighting that all remind you of Visual Studio.</p>
<p>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.</p>
<p>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 =)</p>
<ul>
<li><a href="http://www.jetbrains.com/decompiler/">Jetbrains – dotPeek</a></li>
<li><a href="http://www.red-gate.com/products/dotnet-development/reflector/">Redgate - Reflector</a></li>
</ul>