Rory Primrose

Learn from my mistakes, you don't have time to make them yourself

View project on GitHub

WCF and large messages

I am getting some interesting results when messages are returned from a WCF service. Small responses come through fine. When the responses start to get large, I run into the QuotaExceededException exception. This is fine because you can increase the MaxReceivedMessageSize configuration value on the client endpoint. This starts to fail when the size of the data continues to increase and eventually I get the exception WebException: The underlying connection was closed: The connection was closed unexpectedly__.

The service call is still being made (I can debug it), but it seems that the error is coming back quick enough that it is a problem with the server endpoint, rather than client endpoint or configuration on the client.

Anyone come across this before???

Read More

WCF and caching with a dash of IOperationBehavior

I have been looking at caching support and WCF recently. I have come across a few solutions. These are:

  1. Calling through HttpRuntime to get at the ASP.Net cache
  2. Using Enterprise Library Caching Block
  3. Rolling your own implementation, usually storing data in a Dictionary<String, Object> collection.

I have problems with 1 because that ties your WCF service down to an IIS and HTTP solution which is not good design. Option 3 is also not that great because typically this is built as a ‘quick and dirty’ solution that doesn’t support any cache dependency or cache expiration policies. I haven’t played with 2 yet, but it looks like that will be the go.

On a side note, I came across a code sample by Scott Mason (where’s the blog Scott???) that uses an IOperationBehavior implementation to hook the operation call to provide caching support outside the actual implementation of the service operation. This is a great idea. The only thing I don’t like about it is that operation behaviors can’t be set via application configuration. They can only be assigned to an operation (WCF method) via a custom attribute on the method or via the behaviors collection at runtime. Pity, it would be so nice if you could plug in different behaviors via configuration.

Read More

Databinding not firing

Here’s a little tip. If your databound control is not firing it’s databinding, make sure that the control and all of its parents are visible on the page. If it isn’t visible, OnPreRender doesn’t fire and therefore your databinding won’t either. Makes a lot of sense. There is no point having the overhead of databinding if you are not going to display anything. That just wasted a couple of hours on a really simple mistake.

Read More

Change the VS2005 environment layout

Visual Studio has this really nice setup page when you first run it after install where it asks you what kind of development environment you are familiar with, such as VB, C++, General etc etc. This is really cool, but not so cool when you pick the wrong one. Anyone know how to get prompted with this page again? There are no obvious registry entries that I can tweak.

Hey, don’t bother answering. I just figured it out. The import/export settings dialog allows you to reset the IDE to one of those values. Go to Tools -> Import and Export Settings -> Reset all settings -> No, just reset settings, overwriting my current settings and then select the IDE style you want.

Read More

Nested using statements

The using statement in the .Net framework is a really good way of neatly using and disposing of an object in your code. It is certainly much more elegant than having Try/Catch/Finally blocks where you manually dispose of your objects. I do however have a minor issue with nested using statements. I can’t put my finger on it, but it just doesn’t seem that ‘right’ to me. Maybe it just looks ugly.

The following is an example taken from John Papa’s latest Data Points MSDN Magazine article:

Read More

So you still can't have a path more than 260 characters???

I got hit with an issue yesterday when the local path of a file in TFS had a length greater than 260 characters. I couldn’t run a Get Latest and the IDE also seemed to hang on opening other projects. It reminded me about a situation a couple of years ago when I hit this same issue using longer paths in the framework.

Using reflector, I can see the following code in quite a few places in the framework.

Read More

Binding data to ObjectDataSource parameters

Have you ever needed to have nested databound controls using multiple ObjectDataSources, where the nested ObjectDataSource has a select parameter that requires a databound value itself?

You have no doubt tried the following:

Read More

Neovolve.Schema.Extensions 1.0 released

Neovolve.Schema.Extensions is a project that will do entity mapping for web reference code generations from a WSDL.

When you update a web reference in the Visual Studio IDE, it will get the latest version of the WSDL and generate code to access the web service. As part of this process, it will generate any object types that are exposed by the web service. If you have access to those object definitions on the consumer end point, you will have problems with these object types because the code generated Reference.cs class will use it’s own code generated versions of your object types rather than the ones you really want to use.

The schema extensions get around this problem. When the IDE updates a web reference, it will check against the schema extensions to ask whether the extension understands the object type. The extension has the opportunity to return a different object type, include namespaces and also include assembly references.

This project is configuration driven so that when a web service changes, the configuration can be changed to support the new entity mappings.

After the package is installed, add your object mappings to the configuration file. The configuration for the mappings looks like this:

Read More

ASP.Net errors

Sorry people. This is just a note to myself because every few months I come across the same problems with a new development build.

Failed to access IIS metabase:

aspnet_regiis -i

Mutex Could not be Created:

Solution posted here by Joao Morais.

I have got the same issue. It seems like Visual studio 2005 and the web application pool running ASP.NET 2.0 are having a conflict over the temporary folder.

The workaround I have got for now is:

  • If you have visual studio 2005 is open, close it
  • Go to the ASP.NET temporary folder for v2.0 of the framework
    <Windows dir>\Microsoft.Net\Framework\v2.0<extra numbers>\Temporary ASPNET pages
  • Remove the folder for your application (or all of them)
  • Reset IIS (on a command line window, iisreset) [not always needed, but I had to use it sometimes]
  • First Browse your page from IE (http://localhost/your app)
  • Then reopen Visual studio
Read More