Something every WCF programmer should know!

27 באפריל 2006

When you install WinFX, you also get a long list of Windows Communication Foundation Technology Samples. Just go to C:\Program Files\Microsoft SDKs\Windows\v1.0\samples and locate AllWinFXsamples.zip there. If you extract this zip, you'll get all the technology samples provided with the SDK. To see the list of samples + documentation about them, visit this page. Enjoy!
tags:
no comments

How To: Create Virtual Directory for your Service using Script

How To: Create Virtual Directory for your Service using Script When you want to host your WCF Service in IIS, you should follow several steps: 1. Your service should compile to \bin directory instead of \bin\debug2. You must change the name of the configuration file from app.config to web.config3. Create a .svc file in a specific format.and4. Create a virtual directory in IIS that points to the physical location of you service (probably not a subdirectory of wwwroot..) I am using 2 scripts for creating and removing virtual directories for my WCF Services. You can find them...

CAB isn't so easy to learn…

24 באפריל 2006

After spending a few hours trying to figure out the responsibilities of all the elements of CAB, I found out that I am not the only one who had difficulties... Szymon Kobalczyk has built a Pet Shop application upon CAB in order to learn the new application block. During that application develpment, he published his conculsion in a series of posts: Understanding Composite UI Application Block: Part 1, Part 2, Part 3, Part 4, Part 5, Part 6, Part 7. Finally you can download the PetShop sample from here, using the installation notes from here. Enjoy!
tags: ,
2 comments

Implementation of lock keyword

The lock keyword can be used to ensure that a block of code runs to completion without interruption by other threads. This is accomplished by obtaining a mutual-exclusion lock for a given object for the duration of the code block. the lock keyword is implemented with the Monitor class. For example: lock (x){   DoSomething();} Is equivalent to: object obj = (object)x;System.Threading.Monitor.Enter(obj);try{   DoSomething();}finally{   System.Threading.Monitor.Exit(obj);} Using the lock keyword is generally preferred over using the Monitor class directly, both because lock is more concise, and because lock insures that the underlying monitor is released, even if the protected code throws an exception. This is accomplished with the finally...
tags: ,
no comments

WCF Custom Message Headers

23 באפריל 2006

WCF Custom Message Headers Often do we want to pass some data to some or maybe all our service operations. This data is usually context data such as user tokens, or environmental preferences of the user or machine. In these kind of situations, we would rather not add additional context parameters to the contracts or our services, because we don’t want to involve implementation data / context data with the business parameters of our services. A nice and easy way to pass that data is to use MessageHeaders. In order to do this we follow these steps: Add the context data...
tags:
30 comments

CAB Also…

We decided to use the Composite UI Application Block for our Smart Client side, so I am happy yo announce that this blog will also include thoughts, examples and conclusions about it.   To briefly introduce CAB: The Composite UI Application Block is designed to help you build complex Windows Forms-based applications. It assists you by providing an architecture and implementation that uses the common patterns found in front-end, line-of-business (LOB) applications.   Building an application with the Composite UI Application Block provides the following benefits: Quality and consistency for architecture teams Increased productivity and faster ramp-up time for large developer teams Consolidation of...
tags: , ,
no comments

Basic Service Solutions

21 באפריל 2006

Everytime I sit down to write some WCF code to check out a new idea of mine, I find myself spending the first few minutes writing the same code, just to create a basic service to begin with. I created 2 solutions that will be used as basic sevice templates for me: EchoServiceTemplate and EchoServiceLight. EchoServiceTemplate  seperates the service project from the host project, and seperates the client project from the service agent project (=Client Proxy). Additionaly, this project usese configuratino files to config the bindings, endpoints, behaviors etc. EchoServiceLight is a smaller solution that doesn't contain configuration files at all. Here are the solution...
tags:
no comments

Resolver must be specified. The default resolver (PNRP) is not available

20 באפריל 2006

Resolver must be specified. The default resolver (PNRP) is not available PeerChannel is part of the framework that enables development of managed Peer-to-Peer applications.More details about Peer Name Resolution Protocol (PNRP) here. If you're developing a P2P application using WCF, and you run into the following exception when trying to open the service host:"System.InvalidOperationException: Resolver must be specified. The default resolver (PNRP) is not available." Since PNRP service is not enabled by default on Pre-Vista platforms you need to follow the steps below to make sure PNRP is up and running: 1. Go to Start >...

WCF Configuration Schema

18 באפריל 2006

WCF configuration schema Feb CTP installation does not update the WCF Configuration Schema, therefore the Intellisense will not match the changes that were made in this version. If you want to have Intellisense support to modify the WCF Configuration files in the February CTP, you will have to download that schema and replace the existing schema in C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas. This is a temporary fix for a bug in the February CTP. Enjoy!
tags:
2 comments

GenericProxy<T> at your service

17 באפריל 2006

As a client that wants to communicate with the service, there are several ways to do so: 1. Use ChannelFactory<T> and call the service: ChannelFactory<IContract> cf =    new ChannelFactory<IContract>("endpoint");IContractchannel = cf.CreateChannel();channel.DoOperation(); 2. Using svcutil tool that generates a typed proxy for you.3. Implement a typed proxy that inherits from ClientBase<T>. Here is a code sample of a generic proxy. This proxy also inherits from ClientBase<T>, but allows you not to created a specific class for each service. Additionaly I extended the class by overriding the CreateChannel method, where i added the credentials for the call. /// <summary>/// Generic Proxy for service calls./// </summary>/// <typeparam name="T">The...
tags:
2 comments