WCF Fault Exception

In this example, we will show how to use the FaultException when catching errors in a WCF service. First, create a new WCF service: Our service will be a calculator, that will perform a divide operation. We will rename the files created so we have: Calculator.svc ICalculator.cs In ICalculator, change the code to be below. This is our service contract and operation contract: using System; using System.Collections.Generic; using System.Linq; using … Continue reading WCF Fault Exception

WCF Specify Names of Contracts

Consider a WCF service that returns some text that you entered. The service has a contract called IService1 and an operation called GetData. When we run the service in our test client, we see: The code for this is: using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; using System.Text; namespace Carl.TestWCF { [ServiceContract] public interface IService1 { [OperationContract] string GetData(int value); } } Let’s say we … Continue reading WCF Specify Names of Contracts

JavaScript Promises

JavaScript promises are a way in JavaScript to write asynchronous code in a synchronous way. They are asynchronous callbacks, but in terms of error handling are much more readable. Here we will go through an example of how to use promises. We define a promise as below, with 2 parameters, resolve and reject: new Promise((resolve, reject) If the promise is resolved, we can perform an action, and if it is rejected, … Continue reading JavaScript Promises

JavaScript Callback Functions

A callback function in JavaScript is a function passed to another function that is then called after an event has occurred. This is useful when you don’t know how much time the function will take to complete, such as a call to a web API. In the simple example below, we have a function called callback() that writes to the console. We then have a function called testCallback() that calls the … Continue reading JavaScript Callback Functions

JavaScript in the Dynamics CRM Developer Toolkit

The Dynamics CRM developer toolkit allows you to manipulate JScript resources as well as other artifacts. In Dynamics CRM, create a new solution and add a new Web Resource: In Visual Studio, from the Developer Toolkit, create a new project: Now in your project, right click and select Add to packaging project: You can now add code to the file from within Visual Studio: Update and save the .js file: … Continue reading JavaScript in the Dynamics CRM Developer Toolkit

Namespaces in JavaScript

Namespaces are used to help organize code into logical groups. An example of a namespace is MyCo.ERP.Customers, which may contain code regarding ERP Customers. I could also have a namespace called MyCo.CRM.Customers. When writing an app, I can reference each piece of code using their fully qualified name to avoid confusion of what methods I would like to run. In languages like C#, namespaces are easily implemented. In JavaScript, we can … Continue reading Namespaces in JavaScript

Dynamics CRM SDK, Templates and Developer Toolkit

To install the Dynamics CRM SDK, go through these steps. First, download the relevant SDK version. Here we will install for Dynamics CRM 2013. http://www.microsoft.com/en-gb/download/details.aspx?id=40321 Select to download: Run the downloaded exe: Click to accept: Select a location to extract the files. The SDK files will then be extracted: From here, you can browse to the Templates folder to install the SDK Templates for Visual Studio. Run the VSIX file: … Continue reading Dynamics CRM SDK, Templates and Developer Toolkit

JavaScript === (Triple Equals)

The triple equals sign in JavaScript means “equality without type coersion”. That means, the type and values must both be equal. Take for example the scenario where 0 is false. If we compare with 2 equal signs, the following statement is true. This is because the equality operator converts if they are not of the same type: 0 == false // true If we compare the same 0 and false … Continue reading JavaScript === (Triple Equals)

Using Fiddler with Web API

In this post, we will examine using Fiddler to send requests and receive responses from an ASP.NET Web API. I have a Web API sample that looks like the following: There are different HTTP verbs, including: GET PUT POST DELETE The Customers API is very simple – it integrates with a SQL Server table called Customers with 2 fields – CustomerId and CustomerName, with the data: Start Fiddler. We will … Continue reading Using Fiddler with Web API

Running a .NET Console App in Silent Mode

In .NET, you may need to run your console app in silent mode. To do this, create a new console app. Our app will open a webpage using IE: [sourcecode language=”CSharp”] using System; using System.Diagnostics; namespace Carl.SilentConsoleApp { class Program { static void Main(string[] args) { Process.Start("IExplore.exe", "www.test.com"); } } } [/sourcecode] To run in silent mode, set the Output type in the properties of the code to Windows Application: … Continue reading Running a .NET Console App in Silent Mode