Tuesday, 20 October 2015

Introduction     Starting with IIS 7, we can have IIS hosting application which can run on separate App-domain. Running application on separate App-domain is required when we need application to work in isolation i.e. to prevent applications in one application pool from affecting applications in another application pool on the server. An application can have several virtual directories, and each one will be served by the same App-domain...
Introduction     In this post we will see how we can identify if the application has been maximized or it is restored to normal state. We will use the Resize event equivalent in WPF which is SizeChanged event. We will subscribe to this event and will check the window state to identify if the window has been maximized or it is restored to normal. Application.Current.MainWindow.SizeChanged += WindowSizeChanged; private void WindowSizeChanged(object sender, SizeChangedEventArgs e) { this.HandleWindowState(); } private void HandleWindowState() { ...

Saturday, 17 October 2015

 Introduction   Here in this article we will see how to configure and host a WCF service in IIS 8. When we want to expose our service to internet, hosting it in IIS is the easy and effective way to do it. When you host it in IIS, it comes with all the added advantage of the web server. If you don’t want to host in IIS, you could still do that with a console application running in a server machine. To know more on hosting a service...

Monday, 12 October 2015

Introduction     In this article we will see how to host a wcf service using the wsHttpBinding. When you use http, you would normally host it in IIS, but if you would like to host it in a console application, you could follow this article. Here we will try to host a service with a wsHttpBinding and will expose a MEX endpoint in order to expose the metadata so that any tool which can generate a proxy can use it. Here in this example we...

Tuesday, 6 October 2015

Introduction     There are scenarios where we have to show a standalone message box even before the application main window is launched. In such scenario, we need to do something different. Say if we have a composite application with a bootstrapper, and we want to show some error while running a bootstrapper, it may look difficult because we don’t have a parent window. In such scenario, we can show the message box as shown below. private static void ShowError(string message)         {      ...

Wednesday, 30 September 2015

Introduction       This post is a continuation of [Article] WPF Wizard control with MVVM support. Here I am trying to address some of the concerns people have regarding wizard control. This include 1. How to share/collect data from each view. 2. How to control the navigation or how to validate before navigation. To know more on the basics, please refer to the parent article. Here I have modified the wizard control files....

Tuesday, 22 September 2015

Introduction  In this article we will see how to call a WCF service without adding a service reference. In this article we will see two ways of calling WCF service method. One is to call the WCF service method on the fly and second is by creating a custom proxy without the help of SvcUtil or any other tool. We will be using a two way service in this article...
Introduction  There are cases when an operation has no return value, and the client does not care about the success or failure of the invocation. To support this sort of fire and forget invocation, WCF offers one-way operations. In this article we will see how to create a one way service which responds to client via callbac...

Monday, 8 June 2015

Introduction          In this article we will see how we can cancel a running task. Task class in .net library is extremely useful when you want to handle thread. Developers don’t have to create or maintain thread explicitly. Methods executed by a Task typically execute asynchronously and it uses background threads from the thread pool. There is no direct way of cancelling a task. .Net framework provides CancellationToken  which we can use to cancel a task with limitation. We will first look at how to cancel...

Sunday, 7 June 2015

Introduction While I was working with WCF service application, I came across a situation where I am hosting my WCF service in a console application and I don't want the console application to show up when my service is up. I fixed it this by Pinvoke a call to FindWindow() to get a handle to your window and then call ShowWindow() to hide the window. I have created a sample code to show how I did this. It is as given below. using System; using System.Runtime.InteropServices; using System.Threading; namespace TestShowHideConsole { internal...
Introduction This error can happen when you use Microsoft Team Foundation Server(TFS) and if you don’t have proper binding files. This can happen if the solution is new in TFS and there are no binding files associated with it. You can easily fix this. To fix it, you have to go to File -> Sourcecontrol-> change source control. Click on the project which don’t have binding and say bind. This will automatically bind your solution with the source control. Do the same for the entire project which don’t have proper bindin...
ContractFilter mismatch at the EndpointDispatcher A "ContractFilter mismatch at the EndpointDispatcher" can happen because the client could not process the message because no contract claimed it. This can happen because of the following reasons: Your client and the service have different contracts in between. Your client and service is using a different binding in between. Your client's and service's message security settings are not consistent in between. Most of ContractFilter mismatch at the EndpointDispatcher bugs are because you use...
Introduction This post is for those who are working with WCF and at times sulking because of errors which does not show up and who spends lots of time debugging what is going wrong with their service and client. I was working with a WCF service and I came across a situation where my client application is trying to connect to service via proxy and client is waiting for the call to return and it never returns finally it times out. I was not having any clue what was happening. I had application level tracing which was not able to track anything....
Introduction   This fix explained here is helpful if you are using WCF and when you try to access the service, the client throws an exception like "An endpoint configuration section for contract ‘YourContract' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name". How to fix this exception    WCF service can expose more than one endpoint and client can use any of this endpoint but not more than one at a time. This type...
Introduction WPF applications support rich media and graphics, this require styles and styles can be reusable across different window or element in WPF. Here we need a mechanism by which we can share this style across different window or say application. By adding the style in application resource file, we can share it across windows in application but not across application. Here reusable styles need to be utilized and in a managed way. Here WPF provide an easy way to manage these styles and other reusable resources which can be used across...
Introduction  This post will help you in binding a command to a button, where the button is defined in a template say a data template. With normal command binding it won’t work. We need some sort of workaround to achieve this. How to fix this.  Here the requirement is to bind a command to an element which is defined in a template. When we do a normal command binding, it is not aware of the data context and will not resolve. We need to provide the binding with the data context. This can be achieved in many ways say you can do <Button...
Introduction In this post we will see how to fix the exception due to mixed mode assembly while working with version 4.0 of runtime. Background I was working with a project which uses an older mixed mode assembly and I got an exception like mixed mode assembly is built against another version of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information. When I was able to fix this, I felt like this should be shared with all so that people can save their time. Using the code Mixed mode assembly is...
Introduction In this post we will see how to fix the exceptions like this which hapens even after adding proper dll(s). Here in this post we will see how to fix exception, "The type or namespace name Data does not exist in the namespace Microsoft.Practices.EnterpriseLibrary (are you missing an assembly reference?)" Background I was working on a project when I encountered one exception which was The type or namespace name 'Data' does not exist in the namespace 'Microsoft.Practices.EnterpriseLibrary' (are you missing an assembly reference?) I...

Sunday, 8 March 2015

Introduction You may experience this error if you try to compile a visual studio solution/project where it is referring to this Microsoft.Office.Interop.Outlook from GAC. This could also happen in a build server where you don’t have outlook installed. You may feel like you hit the dead end where you are forced to install the licensed Microsoft office tools. But we have another alternative which is completely free and ethical. How did I fix this?          This is the nuget package. We have a nuget library package...

Friday, 6 March 2015

Introduction You may experience this error if you try to compile a visual studio solution/project where it is referring to Microsoft.Office.Interop.Excel from GAC. This could also happen in a build server where you don’t have or want any tools which are licensed because you don’t want to pay for it as you spawn servers at runtime. You may feel like you hit the dead end where you are forced to install Microsoft office tools. But we have another alternative which is completely legal and ethical. How did I fix this? This is the nuget package. We...

Wednesday, 25 February 2015

Introduction We may get this error when we try to execute an application which has CPP component. Here MSVCP100 is a file which should be installed along with Microsoft Visual C++ 2010 Re-distributable Package. Here 100 means 2010 and D means debug version. This error occurs only when you are trying to run your application which is compiled using the “debug” configuration instead of “Release”.      Here when you try to run the application which was the debug output, then it would expect the appropriate file which has the Debug...

Monday, 19 January 2015

Introduction In this post we will see how to add hot keys to WPF window. Hot keys are keyboard shortcuts with which we can easily navigate through the window without the help of a mouse. Hot keys are those which when pressing “Alt”+ hotkey character will take you to the control associated with that hot key. Background When we have a window, which have many controls we need hot keys which will help users to navigate through the UI controls. When users are used with keyboard, they tend to use keyboard itself and avoids mouse most of the time....