Why is That First WCF Operation SO Slow?

If you have ever developed and worked with a WCF service you may have noticed that the very first time you connect to a newly started instance of the service there can sometimes be a noticeable delay before the service responds. But invoking subsequent operations often seems almost instantaneous. Usually the delay is relatively short, perhaps even just a fraction of a second, but still noticeable. Well earlier this week I encountered a WCF service that exhibited this behavior, but the delay for the first operation was almost three minutes! Something had to be done.

Some time later, after much debugging, web searching and more than a little head scratching, we realized that the “problem” that we were seeing was actually “by design” in WCF and was related to the generation of metadata for the service. It turns out that if “metadata exchange” is enabled for the service then WCF generates the metadata, regardless of whether anyone is currently requesting it or not, at the time that the first operation is requested by a client. Often the generation of the metadata takes almost no time at all, but as the size and complexity of a service grows (in terms of the number of operations exposed, the number of parameters, the number and nature of complex types exposed, etc.) the time taken to generate the metadata grows. In the case of this particular service there were over 800 individual operations defined, with lots and lots of complex types being exposed, and the service was still growing!

The only time you need metadata exchange enabled is when you need to access the WSDL for the service, so in simple terms whenever you need to do an “Add Service Reference” or “Update Service Reference”. The rest of the time having it enabled is just slowing things down at runtime.

I can’t tell you exactly how to enable and disable metadata exchange with your service, because there are several different ways it can be configured, but it’s likely going to be one of these:

  1. A <serviceMetadata/> token used in the <serviceBehaviors> section of a Web.config or App.config file.
  2. An <endpoint/> token that uses the IMetaDataExchange contract defined in a <service/>section of a Web.config or App.config file.
  3. Code that does the equivalent of one of the two options above.

So the lesson learned was to enable metadata exchange only when it is needed, for the purpose of creating or updating client proxy code; the result was an almost instantaneous response from the service once metadata exchange had been disabled. Of course it goes without saying that metadata exchange should NEVER be enabled on production services.

Posted on June 25, 2015 at 12:06 pm by · Permalink · Leave a comment
In: Software Development · Tagged with: , ,

Old Dog … New Tricks … Done!

The old adage tells us that you can’t teach an old dog new tricks. But after the last three days, I beg to differ! It’s been an interesting few days for sure; fun, challenging, rewarding and heated are all words that come to mind when reflecting on the last few days. But at this point, three days into a four-day engagement, I think that we may just have dispelled that old adage. For one this “old dog” certainly feels like he has learned several new tricks.

So what was the gig? It was to visit a company that has an extensive application deployed on OpenVMS, and to help them to explore possible ways to extend the reach of those applications beyond the current OpenVMS platform. Not so hard I hear you say, there are any number of ways of doing that. xfServerPlus immediately comes to mind, as do xfODBC and the SQL Connection API, and even things like the HTTP API that could be used to allow the OpenVMS application to do things like interacting with web services. All true, but there was one thing that was threatening to throw a “spanner (wrench) in the works”. Did I mention that the application in question was developed in COBOL? That’s right, not a line of DBL code anywhere in sight! Oh and by the way, until about a week ago I’d never even seen a single line of COBOL code.

Now perhaps you understand the reason that challenging was one of the words I mentioned earlier. But I’m up for a challenge, as long as I think I have a fighting chance of coming up with something cool that addresses a customers needs. And in this case I did. I didn’t yet know all of the details, but I figured the odds of coming up with something were pretty good.

Why all of this confidence? Well, partly because I’m really good at what I do (can’t believe I just said that), but seriously, it was mainly because of the fact that a lot of the really cool things that we developers just take for granted these days, like the ability to write Synergy .NET code and call it from C#, or write VB.NET code and call it from Synergy .NET, have their roots in innovations that were made 30+ years ago by a company named Digital Equipment Corporation (DEC).

You see OpenVMS had this little thing called the Common Language Environment. In a nutshell this meant that the operating system provided a core environment in which programming languages could interoperate. Any language that chose to play in that ball park would be compatible with other such languages, and most languages on OpenVMS (incuding DIBOL and DBL) did just that. This meant that BASIC could call FORTRAN, FORTRAN could call C, C could call PASCAL and … well you get the idea. Any YES it means that COBOL can call DBL and DBL can call COBOL. OK, now we’re talking!

So why is this such a big deal? Well it turns out that Digital, later Compaq, and later still HP didn’t do such a great job of protecting their customers investments in their COBOL code. It’s been quite a while since there was a new release of COBOL on OpenVMS, so it’s been quite a while since OpenVMS COBOL developers had access to any new features. This means that there isn’t a way to call OpenVMS COBOL routines from .NET or Java, there isn’t a way for OpenVMS COBOL code to interact with SQL Server or Oracle, and there isn’t an HTTP API … so don’t even think about calling web services from COBOL code.

But wait a minute, COBOL can call DBL … and DBL can call COBOL … so YES, COBOL CAN do all of those things … via DBL! And that fact was essentially the basis for my visit to Toronto this week.

I’m not going to get into lots of details about exactly what we did. Suffice it to say that we were able to leverage two core Synergy/DE technologies in order to implement two main things:

  1. A generic mechanism allowing COBOL code executing on OpenVMS to interact with Windows “stuff” on the users desktop (the same desktop that their terminal emulator is running on).
  2. A generic mechanism allowing Windows “stuff” executing on the users desktop to interact with COBOL code back on the OpenVMS system.

The two core technologies have already been mentioned. Outbound from OpenVMS was achieved by COBOL calling a DBL routine that in turn used the Synergy HTTP API to communicate with a WCF REST web service that was hosted in a Windows application running in the users system tray. Inbound to OpenVMS was of course achieved with a combination of xfNetLink .NET and xfServerPlus.

So just who is the old dog? Well as I mentioned earlier I probably fall into that category at this point, as do several of the other developers that it was my privilege to work with this week. But as I set out to write this article I must admit that the main old dogs in my mind were OpenVMS and COBOL. Whatever, I think that all of the old dogs learned new tricks this week.

It’s been an action packed three days but I’m pretty pleased with what has been accomplished, and I think the customer is too. I have one more day on site tomorrow to wrap up the more mundane things like documentation (yawn) and code walkthroughs to ensure that everyone understands what was done and how all the pieces fit together. Then it’s back home on Friday before a well deserved vacation next week, on a beach, with my wife.

So what did I learn this week?

  1. I really, really, REALLY don’t like COBOL!
  2. OpenVMS was WAY ahead of its time and offered LOTS of really cool features. Actually I didn’t just learn this, I always knew it, but I wanted to recognize it in this list … and it’s MY BLOG so I can Smile.
  3. Synergy/DE is every bit as cool as I always believed; and this week I proved it to a bunch of people that had never even heard of it before.
  4. New fangled elevators are very confusing for old dogs!

UX Design; Elevator Controls

Those of you who attended the recent DevPartner conference in Philadelphia will no doubt remember the excellent presentation on UX Design that was given by guest speaker, Billy Hollis. During his presentation Billy cited photographs of a couple of elevator control panels. He used one as an example of bad design, the other an example of good.

I won’t show the actual photos that Billy used (sorry, you had to be there for that!) but in a nutshell the layout of the buttons and other information (floor numbers, etc.) on the first panel was at best confusing. There was clear physical evidence that users had been confused by the panel and frequently had not understood how to operate the elevator!

The second example was much a much better panel design. The designer had successfully used techniques such as visually grouping related things together in a way that made the correct operation of the elevator a much more obvious task … intuitive even.

Well, upon arriving at a customers office building in Toronto, Canada earlier today I encountered an elevator control panel that, for me at least, took the confusion to a whole new level.

I should make it clear that the elevator in question was one of a cluster if four in the lobby of a shared office building, and that I was arriving at the customer site at about the same time that everyone was arriving at work. The point is that the lobby was pretty busy at the time, it wasn’t as simple as just walking up and pressing an “I want to go up” button.

No problem I thought, it may be two or three elevator cars before I get to make the final step of my journey up to the 4th floor. I’m a few minutes early and all is good.

image1Finally my turn came, I waited while a few other people stepped on, then I took my place in the elevator car. Intuitively I spun around to determine whether one of my elevator buddies had already pressed the 4th floor button, and I was ready to press it myself if not. The panel opposite is what I encountered.

Now I like to think of myself as a reasonably bright guy, so I instantly figured it out; the buttons would be on the OTHER SIDE of the door. And I was correct … well … kind of. I glanced to the opposite side of the elevator door … and saw an identical panel on that side too!

Not wanting to appear totally inept I just waited quietly until the other people got off at their (somehow) chosen floors … and no, unfortunately nobody else was going to 4.

The doors swished closed and I was finally alone in the elevator. I don’t remember exactly what my out loud remark to myself was, but I believe it started something along the lines of “WHAT THE ….”. So, patiently I waited and sure enough after a little while the doors once again swished open and I was back where I started from in the lobby!

I’ll be honest with you, I was getting a little “pissed” at this point (excuse my language, but its true). But not wanting to appear like a total fool I stepped away as if I had intentionally returned to the lobby, and waited for the crowd to clear … all the time subtly (I thought) observing to see HOW THE HECK THESE FREAKING ELEVATORS WORKED!!! And then … I saw it … everything instantly became clear. The floor selector buttons were indeed on the other side of the elevator door … they were on the OUTSIDE!!!!

IMG_0957Yep … believe it or not in this building you need to indicate which floor you want to go to BEFORE you step on to the elevator. After you have stepped on it’s too late; way too late!

And further, having selected your intended destination on the small tough-screen display in the lobby you are then instructed WHICH of the four elevators (conveniently labeled A, B, C and D) you should step onto in order to reach your desired floor!

Actually this is a pretty clever system, but other than the fancy 6” touch screen display there was absolutely nothing to indicate that anything was different here. Brilliant system but totally unintuitive … and so very frustrating for first-time users. Which I guess was one of the points that Billy was making in the first place.

Posted on June 1, 2015 at 3:09 pm by · Permalink · One Comment
In: Just for Fun · Tagged with: 

All Selective

During DevPartner 2015 a number of people ran through the Utilizing the Repository tutorial which sets out to demonstrate how the meta-data stored in the repository describing your Synergy database can be utilized when building a modern Windows Presentation Foundation desktop application using Synergy and the Symphony Framework.

Using your repository, CodeGen and the associated Symphony Framework templates you can build, from the ground up, a complete WPF application, and this is exactly what you do during the tutorial.

Using the Model-View-View Model pattern you code-generate the model elements as repository based data objects that extend the base Symphony Framework DataObjectBase – this provides field level properties with validation and data bindings. Then we code generate the view – the UI element the user interacts with. The view comprises of windows containing the individual edit controls which in turn use code generated styles. These styles define the visual attributes and data bindings of each field in the repository.

Great – you would think. But I’ve been asked about a default behaviour of a WPF application a number of times and again at the conference, and that is the fact that edit controls, specifically text boxes, don’t auto-select all content when they receive focus. I also find it frustrating but thus far have been unable to think of a solution. “It’s a deal breaker” according to Gayle – who’d just completed the tutorial. Well considering Gayle is a rather fine chap I guess it’s time for me to look at the problem again. I spoke with Jeff @ Synergex who pointed me to a blog by Oliver Lohmann which addresses just this problem.

The solution is to register a behaviour against the TextBox control and handle the GotFocus event – and in the event handler force the selection of the data in the TextBox control. Simple!

And simple it was – and it usually is when you are looking for that “complex” answer. I’ve not done much with behaviours so far, but I think that is about to change! The Symphony Framework has been updated (did that on the plane home) and I’ll be releasing that to GuGet very shortly. The Symphony Framework “style” template will be updated – it’s now released as part of CodeGen – to reflect the new capabilities and normal “behaviour” will be resumed.

Learning REST Basics

One of the sessions that I presented at the recent DevPartner Conference was on the subject of building RESTful web services using ServiceStack. The basic concepts of REST are often difficult to grasp when you’re first getting started, but while browsing this morning I came across a web site that I thought was a great REST resource, and in particular included a video that I thought did a really nice job of explaining the basic concepts of REST.

The site is http://www.restapitutorial.com/ and the video can be found at http://www.restapitutorial.com/lessons/whatisrest.html

Posted on May 23, 2015 at 1:48 pm by · Permalink · Leave a comment
In: Recomended Websites · Tagged with: 

Synergy .NET Platform Targeting Options

One of the many options that is available to developers each time they create a new project in Visual Studio is how to configure the platform targeting options in the project properties dialogs Build panel. In the latest versions of Synergy there’s probably not much to worry about because the default values probably do exactly what you want most of the time, but the default values were not the same in some older versions of Synergy .NET, so it’s a good idea to have a good understanding of what your options are, and what the implication of choosing each option is.

In Synergy 10.3.1a we’re talking about two options; the Platform target drop-down and the Prefer 32-bit checkbox.

Project Build Options

The Platform target drop-down allows you to select from three different ways that the assembly that is created by your project (the .DLL or .EXE file) can be created; essentially you are choosing which .NET CLR (and Framework) will be used to execute your code. The options are:

Any CPU (default) Assembly can be executed by either the 64-bit or 32-bit CLR, with 64-bit preferred.
x86 Assembly can ONLY be executed by the 32-bit CLR on an Intel x86 CPU.
x64 Assembly can ONLY be executed by the 64-bit CLR on an Intel x64 CPU.

It is important to understand that we’re not talking about which Synergy runtime components will be used, we’re talking about which .NET CLR will be used, and the matching Synergy runtime components must be present on the system in order for the assemblies to be used.

The Prefer 32-bit checkbox (which was added in Synergy 10.3.1a and is only available when the platform target is set to Any CPU) provides the ability for you to determine that even though your assembly will support both 32-bit and 64-bit environments, you would prefer that it executes as 32-bit if a 32-bit environment is available.

The chart below summarizes which environment (32-bit or 64-bit) will be selected for all possible combinations of platform targeting settings and deployment platform.

Framework Selection Grid

A red n/a entry in the table indicates that an assembly would not be available for use in that particular environment.

So what’s the take-away from all of this? Well it’s pretty simple; Stick to the defaults unless you have a good reason to do so. The current default is Any CPU, Prefer 32-bit which means that on Intel x86 and x64 systems your apps will run as 32-bit. This in turn means that you only need to install the 32-bit version of Synergy on runtime only systems unless you also need to run services such as license sever, xfServer, xfServerPlus or SQL OpenNET on the same system. Development systems should ALWAYS have 32-bit and 64-bit Synergy installed.

Posted on May 21, 2015 at 10:25 am by · Permalink · Leave a comment
In: Software Development · Tagged with: , ,

DevPartner 2015 – WOW!

That was the week that was the DevPartner 2015 conference in Philadelphia. Ok, so I’m biased but I really have to say this was one of the best conference weeks I’ve had the pleasure to be part of for many years. There were some really great sessions: The HBS customer demonstration rocked! They came to a conference a couple of years ago, did a tutorial on xfServerPlus and with this new found knowledge (and some PSG guidance) created a cool web bolt-on to their existing Synergy app.

We saw some fresh new faces from Synergex: Marty blasted through the Workbench and visual Studio development environments we provide and showed some really great tools and techniques. Phil gave us a 101 introduction to many of the “must know” features and capabilities of Synergy SDBMS – and of course was able to address mine and Jeff’s performance issues – you had to be there:). Roger demonstrated his wizardry to enlighten everyone as to the issues you need to consider when transferring your data within local and wide area networks – I was the bad router!

Bill Mooney set the whole tone of the conference with a great opening presentation showing just how committed Synergex are to empowering our customers with the best software development capabilities available.

My first day’s session followed and gave me the opportunity to demonstrate how you actually can bring all our great tools together to create true single-source, cross-platform applications which run on platforms as diverse as OpenVMS, UNIX and Microsoft Windows and onto a Sony watch running Google Wear!

Steve Ives went 3D holographic with videos from his recent trip to the Microsoft Build conference that showed just how amazing the Microsoft platform is becoming – and we aim to continue to be a first class player in that arena.

So many of our products are reaching a level of maturity that blows the competition away. Gary Hoffman from TechAnalysts presented a session showing how to use CodeGen and Symphony in the real world and showed just what you can achieve today in Synergy.

Jeff Greene (Senior .NET engineer @ Synergex) and I presented a rather informal (read written the night before) presentation showing the performance and analysis tools in Visual Studio 2015 that you can use to identify problem area and memory leaks in your application. Within minutes Brad from Automated System forwarded me an email he’d just sent to his team:

“At the Synergex conference just this morning, they just showed fantastic new diagnostics tools in Visual Studio 2015.  I just put the Team on the trail of potential memory issues with these new tools in a Virtual PC environment so we don’t alter our current developer stations. This could both reduce the memory footprint and improve performance.” – You can’t beat such instant feedback!

The tutorial time gives attendees the opportunity to play with the latest tools on a pre-configured virtual machine – plug in and code! And we continued the hands-on theme with Friday’s post conference workshop – where we built the DevPartner 2015 App from the ground up!


Thanks to everyone for coming and making the conference such a great success. It’s our 30th conference next year so keep your eyes and ears open for dates and details – it will be a conference not to miss!

Build your own CLR

Open source code is all the rage these days, everyone is doing it, even Synergex.  For some years now CodeGen and Symphony Framework have been open source.  They are both available on www.codeplex.com.  What this gives you is the ability to see inside the classes and programs to see, if you are interested, exactly how they are doing what they do. Even Microsoft are joining the open source band wagon – the .NET Framework is open source and the CLR is following!  Where PSG lead, others will follow (LOL – I think that means laugh out loud, so my kids tell me).

Does this mean you are going to grab all the code, build your own CLR and tweak it to make the blue windows green? No, not at all.  What it does mean is that people can now see what’s happening inside the ocne “black box” and move this code to other platforms.  And this obviously helps us Synergy .NET developers.  We can already take advantage of other platforms because of the availability of the .NET framework and CLR components on non-windows platforms.  It’s how we can deploy your next application to that fancy new Android or iOS phone.  It’s how you can take your good received code you wrote 10 years ago, bundle it up into a tablet application with signature capture and have real time “proof of delivery” built into your systems.

Aside from the conference topics there was an interesting question on the Synergy-l list last night.  The request was to display multiple coloured boxes on the screen.  Sounds simple – and using Synergy.Net inside Visual Studio it was!  20 minute later….








All the UI elements (colour, values, images) come from a data bound repository based structure so you could load the contents directly from your ISAM files.  The actual colours and images are selected through switches inside the XAML code based on the values of your synergy data.  I don’t think I’ll be demonstrating this simple example at the DevPartner 2015 conference, but there will be lots of great examples to see, and of course tutorials to step you through how it’s done.  It’s the last day of DevWeek tomorrow which means I’ll be driving my car around the M25 car park trying to get out of central London for hours.  So I’ll make this my last blog from the conference.  As always the conference has been enlightening.


Colour my World

Apparently UI design is more than just picking colours for you controls – who would have guessed it.  Now if the Senior Director of Design @ Infragistics is telling you this then I guess it’s time to listen.  I’m all for a good UI design – but in our world sometimes it’s just too easy to take the “take what we have and make do” approach.  If you have a cell-based or even a UI Toolkit screen cluttered with fields, drop-downs, lists etc. then surely that’s what the users want to see in your shiny new app right?  Well maybe, but then you struggle with new prospects because your UI looks, well, wrong.  The functionality of the application beats the competition hands-down, but often it’s not good enough to even get your foot in the door.  And for all you in-house developers who don’t have a system to “sell” – don’t look away now as your users are just as important to keep happy as the next sales prospect.  Imagine if you had to write that cool new app using “notepad” – no intellisence, drag and drop didn’t exist, only one edit buffer available, the list is endless – but in a nutshell you’d leave and go program somewhere where they provided the best tools for you to do your job.  And so it is the same for your users – give them the tools to perform at their best.

And then we come back to the age old problem – ten-key.  You just can’t beat data entry on a cell based system.  While this is generally accepted as true, there are ways to improve the process.  Reduce or in many cases eliminate the chrome around the application (I think the cool term today is “flatten”).  Does every other field have to be a comb-box – why not let the user enter the “known only to them” code and provide the newbies with a clickable button to “find” the one they want – you’ll soon find them entering the code!  Choose a colour scheme that matches the environment. If you application is for office based people then make the screen light and bright – it’s easier on the eyes in a bright open office.  Or maybe your application is being used in a dark control room – no windows or natural sunlight, so make the application darker and milder to reflect this.  Align your controls, prompts and buttons to a gird like structure.  Don’t overdo the font types and sizes.  And of course there is the 1.617 rule!

It’s interesting that many of the sessions this year are more about making your apps look right and not actually making you aps.


Posted on March 25, 2015 at 3:28 pm by · Permalink · Leave a comment
In: Uncategorized

Secure the Bridge

Today is actually the first “real” day of the DevWeek conference.  As a member of the DevPartner team at Synergex I tend to look at more than just the agenda content when I attend conferences like this – the venue has to be right.  DevWeek this year is being held in a church!  it’s a fully-fledged conference venue, but it’s still a church.

The opening keynote was a dual affair.  The first half was about trees (not the green leafy variety) followed by a presentation about how “estimates are a complete waste of time, effort and resources” – something I can certainly agree with!  If you consider that all estimations are based on guess work, why waste time guessing how long something may take just to get it wrong.  There are other more accurate ways to plan out a project – the biggest challenge is convincing the customer.

Not everything presented at this conference is directly related to coding – and it’s the same at DevPartner 2015. This year we are bringing in people from outside of Synergex to present a different perspective to developing software outside of just “typing Synergy code”.  This will include experts in the field of UI design considerations – so your Synergy applications can sparkle.

One area I’m working on at the moment is security.  The new Symphony Bridge is a web-service architecture that allows direct access to your code and data from any client.  Unlike a traditional Web Service the Symphony Bridge does not expose all your methods and data structures, which is a security concern for old legacy implementations.  It exposes a single point of entry that accepts a single input stream – there are no external indications as to what that entry point is or the format of the input data.  This helps to protect the service from those hackers out there that just want to get into and behind your service.

The security 101 session today was both informative and reassuring that Bridge is doing as much as it can to protect your back end server systems from attack.  I’ll demonstrate some of the built in security features during the “Serving up Success” session.

Posted on March 24, 2015 at 2:16 pm by · Permalink · Leave a comment
In: Events, Software Development