System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL

Windows Vista or later version of windows operating systems has a new security setting that restricts users to run service with default administrative privilege. As a consequence people are migrating or developing in VISTA or Win 7 or Windows 2008 server might encounter the following exception.

HTTP could not register URL http://+:8000/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).

Read more of this post

Advertisements

The maximum message size quota for incoming messages exceeded exception in WCF

This is a common error you get when developing you are consuming WCF service operation that deals with large data.

To overcome this error you need to customize the bindings, service behavior and endpoint behavior of the service.

  1. Customize the binding:

First of all you need to set the maxbufferpoolsize and maxReceivedMessageSize in the binding.

MaxBufferPoolSize  gets or sets the maximum size of any buffer pools used by the transport.  The default is 524,288 bytes.

MaxReceivedMessageSize gets and sets the maximum message size that can be receivied. The default is 65536 bytes.

ReaderQuotas: Defines the contraints on the complexity of SOAP messages that can be processed by endpoint configured with a binding. You need to set the maxBytesPerRead, maxDepth, maxNameTableCharCount,maxStringContentLength.

Read more of this post

UDP Binding Example in WCF 4.5

UDP:

UDP (User Datagram Protocol) is a connectionless protocol that runs on top of IP networks. It is similar to TCP/IP. However, it provides less error handling and recovery that TCP/IP. It provides a direct way of send and receive datagrams over an IP network, primarily used for broadcasting messages across networks.

UDP and WCF 4.5:

WCF 4.5 framework supports UDP bindings. It is one of the new features of WCF 4.5. Following is an example how to use UDP Binding in .Net 4.5

Service Configuration :

<system.serviceModel>

<behaviors>

<serviceBehaviors>

<behavior name=””>

<serviceMetadata httpGetEnabled=”true” httpsGetEnabled=”true”/>

<serviceDebug includeExceptionDetailInFaults=”false”/>

<serviceThrottling maxConcurrentCalls=”1000″ maxConcurrentInstances=”1000″ maxConcurrentSessions=”1000″/>

</behavior>

</serviceBehaviors>

</behaviors>

<services>

<service name=”UdpServiceHost.HelloService”>

<endpoint address=”soap.udp://localhost:8080/” binding=”udpBinding” contract=”UdpServiceHost.IService”/>

<host>

<baseAddresses>

<add baseAddress=”http://localhost:8080/UdpServiceHost/”/&gt;

</baseAddresses>

</host>

</service>

</services>

</system.serviceModel> Read more of this post

Configuring certificates in IIS Express and Windows XP development server

We are on the age of Windows 7 and windows 2008 Server. Configuring certificates on Windows 7 and IIS Development server is lot easier. However, in corporate environment you often hit some limitation. You dont have the obvious choice of choosing your own technology stack. You are often governed by corporate policy and their computer licensing. That restricts your development environment as well. IIS Express gives you a nice compressed version of IIS for development. However it is often a tedious task to configure this when you are working on WINDOWS XP. When you are ask to enable security features in this development environment your task become for difficult. I have found many difficulties in configuring certificates in IIS Express in WINDOWS XP environment. So i thought of sharing this. You need to follow the following steps to configure certificates on IIS Express in WINDOWS XP operating system.

Step 1 : Make a directory in your computer. I Created c:\MyCerts
Step 2: Go to c:\MyCerts

Step 3: Clean up any exiting certificates from your MMC Certification Snap in. Execute the following two commands.
certmgr -del -r localmachine -s TrustedPeople -c -n myCert

certmgr -del -r localmachine -s My -c -n myCert

Above two commands will remove any certificates name ‘mycert’ from localmachine and trustedPeople certificate repository. We are going to create a new certificate name ‘mycert’ in the following steps and deploy it.

Step 4: Generate a new certificate
makecert.exe -sr localmachine -ss My -pe -sky exchange -n “CN=mycert” mycert.cer

Step 5: Import it to MMC Certificate Snap in using the following commands.
certmgr.exe -add -r localmachine -s My -c -n mycert -r localmachine -s TrustedPeople

This will import the certificate to you local computer. Check for mycert in both Personal\Certificates and Trusted People\Certificates. To check that go to MMC snap-in and load certificates.

Step 6: If you are using WIF for Security Token Service (STS), you need to update the thumbnail of the certificate in WebHost\Web.config file. To get the thumbnail of the certificate, go to Personal>Certificates. Double click on “MyCert”. Go to details. Click on Thumbnail. Write down the thumbnail .

Step 7:
Open webhost\web.config file … update the thumbnail … Remember to remove the space in between.

Step 8:
As, IIS Express on XP run under the context of localuser, we need to grant access to localuser on certificate machine key to.
Usually machine key are stored on the following location
C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys
Select the appropriate MachineKey (In my case, I don’t know which one was it so I grant access on both of the file).
Select the file. Right click à go to Properties -> go to security. -> Click add …
Grant Full control to ‘ASPNET’ and Your Log In account.
IIS-Express run in as a local account in your Windows XP. So you need to provide appropriate permission to your local account to access the machine keys.