Microsoft CRM Dynamics, Microsoft Dynamics 365, Web Application, Windows Service

Not able to install windows service using InstallUtil.exe command

We recently faced an issue where we had a few windows services interacting with Dynamics 365 CE instance on prem.

We were using the InstallUtil utility in windows to install the service in all environments and never faced issue with installation, but the service failed to install in Prod.

Here is the InstallUtil command we were using:

InstallUtil "C:\xyz\abc.exe"

The problem was after executing the utility there was no error in console and no error in event logs but we couldn’t see the service in windows services explorer.

Also we checked the count of services before and after running the InstallUti utility and the result was the same

powershell   (Get-Service | Measure-Object).Count

We ended up using the SC CREATE command to install the service and it worked just fine for us.

SC CREATE "abc.exe" binpath="C:\xyz\abc.exe" displayname="abc.exe"

Advertisements
Standard
ASP.NET Web API, C#, Web Application

No HTTP resource was found that matches the request URI

We were getting a very silly error on deploying a webapi based service.

It was a GETAction

[Route("api/OCS/unbarmsisdn/{msisdnparam}")]
public IHttpActionResult UnbarMsisdn(string msisdn)
{

....

}

We were getting the following Error message:

No HTTP resource was found that matches the request URI

 

The problem was simple but can be easily missed.

Let’s look at the method definition again:

[Route("api/OCS/unbarmsisdn/{msisdnparam}")]
public IHttpActionResult UnbarMsisdn(string msisdn)
{

....

}

 

If you noticed there’s a difference between the Method parameter and the Route Decorator parameter. Both parameters should have the same name and you should be able to browse the method using the browser.

 

 

Standard
C#, Web Application

Adding User-Agent HTTP header to a web request from C# code

Recently I faced a small issue while passing User-Agent as part of Http headers.

I was assuming any header can be passed to a Web Request using request.Headers.Add(“Header Name”, “Value”) but I was wrong.

 

User-Agent is actually a property on WebRequest and has to be set like the following:

request.UserAgent=”Value”;

 

Simple issue but good to remember 🙂

Standard