Tuesday, April 22, 2014

TFS Git: Sync button not enabled

For a project I’m using the TFS Git integration. After creating a local branch and committing some changes, I couldn’t sync my changes to the remote TFS repo. The ‘Sync’ button was disabled on the Unsynced Commits screen.

clip_image002

The reason the ‘Sync’ button was disabled is that although I had the branch created locally, this branch didn’t exist yet on the remote TFS repo. I had to create this branch first. This is not possible from inside Visual Studio (yet).

So you have to go to a command prompt and execute the following command to push the current branch and set the remote as upstream:

git push --set-upstream origin new_branch

Friday, April 18, 2014

C# Brainteasers

Looking for some brain gymnastic before starting the weekend? Have a look at Sunny Ahuwanya's C# brain teaser:

I have to admit that I had most of them wrong Verwarde emoticon. It seems there are some dark corners and edge cases in C#…

Go check them out!

Wednesday, April 16, 2014

MongoDB: System error 1067 has occurred.

After installing MongoDB as a windows service I wasn’t able to get it started. Instead the following error message was shown:

The Mongo DB service is starting.

The Mongo DB service could not be started.

A system error has occurred.

System error 1067 has occurred.

The process terminated unexpectedly.

When MongoDB crashes like this, you have to do some clean up work before trying to start it again:

  • Delete the following file inside the /data/db/ directory: mongod.lock
  • mongod.exe –repair
  • Start the mongod service again

Tuesday, April 15, 2014

TypeScript error: Initializer of instance member variable cannot reference identifier declared in the constructor.

In a TypeScript application we are building, we have code similar to the following:

However when we try to run this, TypeScript complains with the following error message:

Error      19           Initializer of instance member variable 'processAllOrders' cannot reference identifier 'that' declared in the constructor.             

I think it’s a bug in TypeScript as I don’t see any reason why this shouldn’t work.

Monday, April 14, 2014

Error in Visual Studio 2013 when creating a new project: “No exports were found that match the constraint"

After installing some updates, my Visual Studio went bananas. When I try to create a new project, it always fails with the following error message:

No exports were found that match the constraint:
ContractName
Microsoft.VisualStudio.Text.ITextDocumentFactoryService
RequiredTypeIdentity
Microsoft.VisualStudio.Text.ITextDocumentFactoryService

No idea what’s causing the issue, but I was able to fix the issue based on the workaround mentioned on the Connect site:

  • Delete the ComponentModelCache folder at %AppData%\Local\Microsoft\VisualStudio\12.0.

Friday, April 11, 2014

Dojo: Esri.request is undefined

On a Single Page Application we are building, we use the ArcGIS API for JavaScript.  This API allows us to bring the power of the ArcGIS GIS functionality into our client application. The ArcGIS API for JavaScript is build on top of the popular Dojo toolkit. This means that we had to integrate Dojo inside our application.

So we added a Dojo config file to our application:

However when we ran the application and tried to load a Dojo module, it failed with the following error message:

Esri.request is undefined

It took us some time to figure out that the issue was related to one specific setting inside our DojoConfig; the async setting. If async is set to true, injected modules will be loaded when require is called. If async is not set, these modules are loaded immediately when dojo.js is loaded.

So to fix it, we updated the Dojo config to:

Thursday, April 10, 2014

The remote certificate is invalid according to the validation procedure

When calling an OData service from inside my ASP.NET MVC application, the call always fails with the following exception:

The remote certificate is invalid according to the validation procedure

The OData service I’m connecting to is available through HTTPS so I would guess that something is wrong with the SSL certificate.

Let’s walk through the checklist:

  • Hostname matches the name used in the certificate: OK
  • Certificate is not expired: OK
  • Encryption level is high enough: OK
  • The full certificate chain is trusted: OK

Mmm, strange. Everything seemed fine. And when I browsed to the OData service directly from the browser, I could get all the data as I would expect.

In the end I figured out that I had to give the MVC application access to the private key of the certificate.

Following steps fixed the problem:

  1. Export the certificate from the OData Service host(don’t forget to export the private key as well).
  2. Open MMC and load the Certificates snap-in.
  3. Import the certificate into the "Local Computer" account on the server where the ASP.NET MVC application is hosted.  Make sure to check "Allow private key to be exported"
  4. Give your IIS 7.5 Application Pool's identity Full Trust access to the certificate.