Open Menu

Synergex Blog


Microsoft Release Visual Studio 2015 Update 2

By Steve Ives, Posted on March 30, 2016 at 10:25 pm

Today, amongst many other things, Microsoft announced the release of Visual Studio 2015 Update 2. We wanted to let you know that if you are doing Synergy .NET development with the current Synergy 10.3.2 beta version then it’s OK to apply Update 2. But if you’re running the 10.3.1 release of Synergy (or an earlier version) you should not install Update 2 just yet. We are currently finalizing and will soon release a hotfix for Synergy 10.3.1 to that will add support for Visual Studio 2015 Update 2, but for now you should stick with Update 1.


Synergy .NET Platform Targeting Options

By Steve Ives, Posted on May 21, 2015 at 10:25 am

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.


Synergy .NET Without Purchasing Visual Studio

By Steve Ives, Posted on June 20, 2012 at 1:16 pm

It occurs to me that we may have forgotten to tell you about something important … sorry! Of course if you were at either of the recent Synergex DevPartner conferences then you will already know this, but if not then “listen up” because this could save you some money!

The development environment for Synergy .NET is provided by Microsoft Visual Studio. For Synergy 9 we support Visual Studio 2010 Professional or higher. If a developer wants to develop with Synergy .NET then they would install Synergy/DE and Visual Studio 2010, and then install “Synergy Language Integration for Visual Studio” (we call it SLI because it’s less of a mouthful) to add all of the Synergy .NET capabilities and templates alongside the other Microsoft languages like C# and Visual Basic. Many developers already have Visual Studio 2010 so this isn’t a problem … but what if you don’t?

Well … good news! In addition to purchasing Visual Studio 2010 there is also a free solution. It’s called Visual Studio 2010 Shell (Integrated) and you can download it directly from Microsoft. Basically the Integrated Shell is a bare bones version of Visual Studio, with all of the other languages stripped out. It’s not much use on its own, but if you install it and then install SLI … hey presto you have a full Synergy .NET development environment!

If you do decide to try this out then please remember that Synergy .NET requires Visual Studio 2010 Service Pack 1, so you’ll need to install that after installing Integrated Shell, but before installing SLI.

You can download the files that you’ll need from these locations:

Visual Studio 2010 Shell (Integrated)

http://www.microsoft.com/en-us/download/details.aspx?id=115

Visual Studio 2010 Service Pack 1

http://www.microsoft.com/en-us/download/details.aspx?id=23691

By the way, when Synergy 10 is released later this year you will have a choice of two development environments. We’ll continue to support Visual Studio 2010, but we’ll also support Visual Studio 2012 … and there is an Integrated Shell available for it too, but the requirements are a little different. There is also something called Visual Studio 2012 RC Shell (Isolated), and you have to install that before you can install the Integrated Shell.

Visual Studio 2012 RC Shell (Isolated)

http://www.microsoft.com/en-us/download/details.aspx?id=29927

Visual Studio 2012 RC Shell (Integrated)

http://www.microsoft.com/en-us/download/details.aspx?id=29912

By the way, it appears that the Visual Studio 2012 RC Integrated Shell installation may have a problem. I found that it reported errors about missing components when I tried to install it. I also found that if I did a reboot between installing Isolated Shell and Integrated Shell – the errors went away!

If you do decide to play with Synergy 10 (the beta will be out very soon now) and Visual Studio 2012, and we really hope that you all will, remember that Visual Studio 2012 is currently release candidate. When the final product ships later in the year there will be new Isolated and Integrated shells to download and install.


Microsoft Removes Installer Project Templates from Visual Studio 2012

By Steve Ives, Posted on June 13, 2012 at 8:09 am

Microsoft has recently announced that the various “Visual Studio Installer” project templates that were included in Visual Studio 2010 will NOT be included in Visual Studio 2012. These project templates are used within Visual Studio 2010 to build Windows Installer setup packages for .NET applications.

I’m writing this post because one of the 2012 tutorials that was published during our recent DevPartner conferences was based on using these these project templates; it showed developers how to build an installation package for a simple windows application. I wanted let customers know that the specific mechanism taught during the tutorial will not work in future versions of Visual Studio.

Bear in mind, however, the end result of the tutorial is a “standard” Windows Installer MSI package, and many of the techniques and concepts presented are still very much applicable to building any Windows Installer packages using other products.

Unfortunately there will no longer be any free tools for building installations included with Visual Studio, so developers will likely have to select one of several third-party products (e.g. InstallShield) to build their installation packages.


Are you ready for Windows 8 and Visual Studio “11”?

By Steve Ives, Posted on May 15, 2012 at 10:59 pm

Microsoft has recently announced that the Release Candidates of both Windows 8 and Visual Studio “11” will be made available during the first week of June, 2012. Are your applications ready?

The annual Synergex DevPartner Conferences are just around the corner, and will present a wealth of valuable information that Synergy developers need to be aware of in order to deploy apps on these new platforms. It’s not too late to sign up, so don’t miss the opportunity.


Windows Reimagined

By Steve Ives, Posted on September 14, 2011 at 12:18 am

Well, all I can say is “WOW”! The first day of the Microsoft BUILD conference is over, and it’s been a LONG day, and it’s been a BUSY day, and it’s been an EXCITING day. Wow!

I’m buzzed … and I’m really quite surprised by that statement. I arrived in Anaheim a little over 24 hours ago, and to be quite honest I was a little skeptical about the whole thing. As you may know from a couple of recent posts, I had started to do some research about what Windows 8 might mean to Synergex, and to our customers, and to our customers customers … and to be quite honest I had more questions than answers. I was more than a little concerned that Microsoft were all set to try to change the Windows world … which they are … but perhaps with less than the amount of (in my opinion) required consideration for existing customers, and applications, and technologies, and tools.

Specifically, I was concerned that there was a lot of talk about HTML5, and of CSS, and of JavaScript … but very little talk about XAML, and C#, and third-party languages like Synergy .NET, and so on. I was concerned that Microsoft were set to not only reimagine Windows, but also reimagine all of the development tools that are used to build Windows applications.

But … big sigh of relief … from me and several thousand other people in the room … although there is a definite emphasis on new development tools which will soon be available within the Microsoft development toolset, i.e. extended support for tools like HTML5, CSS and JavaScript,  there is also a consistent message that existing .NET toolsets are still completely valid and will continue to be so.

On the platform side … WOW! Most of the information to date has centered around videos of demos dating back to early June, and those demos were pretty impressive, Well, I can tell you that things have moved on quite significantly since then, and although Windows 8 is still only in a “Developer Preview” (i.e. pre-beta) state … it’s looking REALLY GOOD!

Of course there are bugs, of course there are glitches, but on the whole people at this conference are pretty excited about what is coming. And that includes the four Synergex employees that are here … after a long day at the conference, and a pretty good stint in the bar afterwards, we’re bouncing ideas around, and coming up with all of these “what if’s”, and seeing the real possibility of Synergy developers being able to fully participate in these exciting new technologies.

Of course some of the reason for this is as a direct consequence of the tens of thousands of man hours of work that have been invested in the various Synergy products in recent years. But also it is with the realization that there is more work still to be done, because the goal posts just got moved in a fairly significant way. But … because of where we know we are now, where we now know we need to be actually doesn’t seem that far away … WOW!

There are exciting times ahead … there are challenges also, but I firmly believe that we’re on the right track.

If you’re interested in the future of Windows then I would strongly recommend that you watch the keynote speech from todays conference, you can find it and many other interesting videos here:

http://www.buildwindows.com

By the way, I am writing this post on my new Samsung Windows 8 “Slate” PC. Those who know me would tell you that I develop on Windows, and Unix, and Linux, and OpenVMS … but I’m an Apple guy at heart. I have an iPhone, and an iPad, and a couple of Macs … and I LOVE those things. But … I think that Microsoft Windows 8 might just change the world. It’s an operating system for the PC, and that PC might just be a Slate (tablet). The point is that today I was convinced that the best of both worlds really can be built into one operating system that can run equally well on different types of devices. I LOVE my iPad but I can’t run hundreds of thousands of existing desktop apps on it, and despite good intentions iOS is jus WAY too restrictive. What Microsoft showed us and gave us today is really cool … it’s a tablet, but it’s also a PC … WOW!


Exposing WCF services using Synergy .NET Interop

By Steve Ives, Posted on September 2, 2011 at 11:20 am

In this post I will explain how a WCF service can be created using a Synergy .NET Interop project. In my earlier post I explained how to use xfNetLink .NET to create a WCF service, which provided an easy way to create a WCF service for developers who were already using xfNetLink .NET and xfServerPlus. Now I want to show you an alternate approach that is somewhat similar in nature, but which does not require the continued use of xfNetLink .NET and xfServerPlus in final solution. Of course this might not be what you want if your Synergy server is a non-Windows system.

This is the fourth in a series of posts relating to the various ways in which Synergy developers can use of Windows Communication Foundation (WCF) when building their applications. The posts in the series are:

  1. Building Distributed Apps with Synergy/DE and WCF
  2. Exposing WCF Services using xfNetLink .NET
  3. Hosting WCF Services in an ASP.NET Web Application
  4. Exposing WCF services using Synergy .NET Interop (this post)
  5. Self-Hosting WCF Services
  6. Exposing WCF services using Synergy .NET

What is Synergy .NET Interop

Before we get started we better make sure you know what a Synergy .NET Interop project is. In a nutshell an Interop project is a way of creating a .NET assembly containing various classes, where the external interface of those classes is defined by a collection of Traditional Synergy xfServerPlus methods, and the Synergy records that are referenced by the parameters of those methods. The idea is that the classes exposed by the assembly created by an Interop project have the exact same external interface that would be created if those same methods were defined in a Method Catalog and exposed via xfServerPlus and xfNetLink .NET. So the primary use case for an Interop assembly is to allow developers with existing applications which use xfNetLink .NET and xfServerPlus to factor those tools out of their solution, resulting in a pure .NET application.

In the same way that GENCS has an optional –W command line switch which essentially transforms the resulting .NET assembly into a WCF service, the Synergy .NET Interop project has a project option which does the exact same thing.

So let’s get started. Here’s how to do it. Remember, an Interop project allows you to expose a Synergy .NET assembly based on one or more traditional Synergy methods and records, but there are some prerequisites:

  1. The Synergy methods must make use of the recently introduced attributes and documentation comments, so that the external interface of the method is entirely defined within the code. The Interop project does not use a Synergy Method Catalog. For more information on this you can refer to a blog post that I wrote back in 2009 called Wave Goodbye to the MDU.
  2. The records that are referenced by the parameters of the methods must be defined in a repository, but this would always have been the case if you were using xfServerPlus.
  3. Generally the data files that are accessed by your methods should be moved to the Windows server where the WCF service will be hosted, so that the files can be accessed locally. If your data files need to stay on a non-Windows server then of course you could use xfServer to access the files remotely.
  4. You’ll need to have a copy of the source code for the Synergy methods available on the Windows development system where you are using Synergy .NET.

These are the steps that you’ll need to complete in order to create a Synergy .NET Interop assembly from your existing Synergy methods and repository structure definitions:

Create an Interop Project

The first step in the process is to create a new Synergy .NET Interop Assembly project:

  • Open Visual Studio and create a new Synergy .NET Interop Project.
  • From the menu, select File > New > Project.
  • In the Installed Templates list select Synergy/DE > Interop.
  • Set the name and location of the new project as required (here I’m naming the project MyInteropAssembly and setting the location to my c:temp folder).
  • Click the OK button to create the new project.

 

image

When you create an Interop project a new source file called SynergyRoutines.dbl is automatically included in the project. This file contains various utility routines that are used by the interop project in order to expose the same interface that xfNetLink .NET does. You shouldn’t need to be concerned with this code, and shouldn’t modify it. Simply close the file.

Add Synergy Method Source Files

Having created the Interop project the next step is to add the source code for your Synergy methods to the project. Remember that the methods that you include in an Interop project are Traditional Synergy subroutines and functions that include whatever {xfMethod} and {xfParameter} attributes are required in order to completely document the external interface of the methods within the source files.

imageFor clarity when creating an Interop project I also like to include my method source files in a folder within the project, and I generally name the folder “Methods”. This is entirely optional though.

  • In solution Explorer, right-click on your Interop project and from the context menu select Add > New Folder.
  • Change the name of the folder to Methods and press enter.
  • Right-click on your new Methods folder and from the context menu select Add > Existing Item….
  • Use the resulting open file dialog to browse to the location of your Synergy method routines, select them all, and then click the Add button to add the routines to your project.

In Solution Explorer your project should now look something like the image on the right.

Before we move on let me make a couple of things clear. Firstly it is important that you know that when you add existing files to a project using Add > Existing Item, those files are COPIED into your project folders. If you prefer to leave the source files in their existing location then you can use Add > Reference Existing Item.

The second thing that you need to understand is that in the example I am using here the nature of the methods that I am using is relatively simple, and the methods don’t have external dependencies on other routines in libraries, don’t use include files, etc. If your methods do have such dependencies then you will need to decide how best to resolve those dependencies.

Set Environment Variables

It is likely that you will need to set some environment variables in order for your code to be able to compile and run. It is almost certain that you will need to at least set the environment variables that allow your repository to be located and accessed, and in the case of the code that I am using, at runtime an environment variable named DAT is used to specify the location of the data files that are accessed by the code.

Synergy .NET development projects include the ability to set environment variables in the development environment via properties of the project:

  • In Solution Explorer, right click on your project and from the context menu select Properties.
  • In the project properties dialog, to the left side, select the tab named Environment Variables.
  • Set whatever environment variables are required in order for your code to compile and run.
  • Save your changes by selecting File > Save from the menu.
  • Close the project properties dialog.

In the case of the code I am using for this example I needed to set the following environment variables:

image

By the way, the tools in Synergy .NET also honor the same mechanisms for setting environment variables as Traditional Synergy on the Windows platform. So if the environment variables that you need are already present in your system environment, or are provided by the synergy.ini or synuser.ini files then you won’t need to set them here.

Build an Interop Assembly

You should now be able to build your interop assembly.

  • In Solution Explorer, right-click on your project and from the context menu select Build.
  • Check the output window, you should see something like this:
------ Build started: Project: MyInteropAssembly, Configuration: Debug Any CPU ------
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

 

imageIf your assembly did not build then you’ll need to resolve any errors that you may have before you proceed. The most likely cause for errors at this point will be external dependencies that are not catered for.

Check out what happened in your project. If you look in Solution Explorer you will notice that a new folder called GeneratedCode was created, and some new source files were added to the folder. These new files are at the center of how Interop projects work.

The method source files that you added to the project, in the Methods folder, were Traditional Synergy subroutines and functions. The job of an Interop project is to expose the functionality of those methods in the same way that xfNetLink .NET’s GENCS utility does, and GENCS creates .NET classes that represent the Synergy methods, and the data structures exposed by those Synergy methods.

The Interop project essentially does the same thing, except that where GENCS created C# code which uses xfNetLink .NET and xfServerPlus to call the Synergy methods, the Interop project creates Synergy .NET code which calls the Synergy methods directly.

In the code used in my example the Synergy methods that I added to the project were all part of an interface named “SynergyServer”. This was defined by the {xfMethod} attributes that were present in each of the source files that I included into the project. You will notice that the GeneratedCode folder now includes a source file named SynergyServer.dbl, and if you were to look in the source file you would see that it contains a class named SynergyServer, which in turn contains methods named GetAddressForUpdate, GetAllCustomers and so on. These methods correspond to the Synergy methods that I originally included in the project.

Additionally you will notice that the GeneratedCode folder also contains several source files which represent the record definitions which are exposed by the parameters of my methods. For each record that is exposed the interop project has created a class to represent that data structure. These classes are named Address, Address_type, Contact and so on.

However, if you were to look in the source files that have been generated into the GeneratedCode folder you might notice that these generated classes do not contain any ServiceContract, OperationContract, DataContract or DataMember attributes. In other words, the classes can’t currently be exposed via WCF.

Note: You should not make changes to any of the code in the GeneratedCode folder, because this code will be recreated each time you build the project. 

Expose a WCF Service

As I briefly discussed in an earlier post, in order for classes to be exposed via WCF it is necessary to apply various attributes to those classes:

Nature of Item Required Attribute
Class containing callable methods ServiceContract
Callable method OperationContract
Class defining a data structure DataContract
Accessible member in a data structure DataMember

 

In an Interop project, these attributes can be automatically added to the generated classes by enabling a project option called “Generate WCF Contracts”.

  • In Solution Explorer, right-click your project and select Properties.
  • In the project properties dialog, to the left side, select the tab named Interop.
  • Check the Generate WCF Contracts option.
  • In most cases it’s also a good idea to set the Generate out parameters property to out instead of the default value of “ref”.
  • Save your changes by selecting File > Save from the menu.
  • Close the project properties dialog.
  • In Solution Explorer, right-click on your project and from the context menu select Build.
  • Check the output window and make sure that your assembly built correctly.

 

Note: The default behavior of generating out parameters as ref is to maintain compatibility with what GENCS does by default, but when exposing a new WCF service to a new client application you would always want output parameters defined as type out.

 

Now take a look at the various source files in the GeneratedCode folder. You should notice that the ServiceContract, OperationContract, DataContract and DataMember attributes are present as required.

Host the Service

That’s it, you just used a Synergy .NET Interop project to define and create a WCF service. Of course before you can actually do anything with the service you will need to host it somewhere. One option is to host the service in an ASP.NET Web Application as described in my earlier post.

However, sometimes developers don’t want to have to setup and maintain an IIS web server simply to host a WCF service. Luckily there are other ways of hosting a WCF service that do not require IIS, and that will be the topic of the next post in this series.


Building Windows 8

By Steve Ives, Posted on August 29, 2011 at 1:50 pm

As Microsoft’s new Build Windows conference draws ever closer the rumor mill about what the focus of the conference will be is gathering momentum. This is due in no small part to the fact that with the conference only two weeks away there is still no published agenda. But that doesn’t seem to have deterred people from attending, I would estimate that there are generally over 10,000 delegates at these events, and this conference has been sold out since early August!

That being said it’s not too hard to figure out from the name of the conference that the focus will be on the next version of the Windows operating system, which Microsoft have “code named” Windows 8! What might be a surprise to a lot of people however is the scale of the change that is on the way next year, because from all available information it’s looking like the default Windows 8 experience will be VERY different from anything that Windows users have experienced in the past.

This suspicion was confirmed recently when Microsoft posted a video entitled “Building Windows 8 – Video 1” on one of their development team blogs. The video was also uploaded to YouTube, and I’ve embedded it in this post … take a look:

As you can see the default Windows 8 experience is very different, and is sure to bring some new challenges for developers who want to deploy applications that take advantage of the new capabilities of the platform. From Microsoft’s demonstration it is clear that traditional Windows applications will continue to be supported, so there is no need to panic, but as software developers we all need to be thinking about how a change of this magnitude could affect our businesses.

For some time now Microsoft has touted WPF and Silverlight as the flagship technologies of choice for building UI’s for .NET applications. But with Windows 8 is all that about to change? The video makes it clear that the primary UI technologies used to build Windows 8 applications are HTML5 and JavaScript, neither of which have a particularly strong toolset presence in Visual Studio 2010. So for many of the developers at the Build Windows conference the main question will be “what’s new in Visual Studio 2012 and .NET Framework 4.5 that will help me build applications for Windows 8?”.

Clearly Microsoft believe that mobile and tablet devices are going to become far more predominant in the future, and are actively planning for this by merging the various operating systems that are used on the various types of computing platforms. And of course they are not alone in this endeavor as Apple’s recent release of OS X Lion also somewhat takes this approach, although not quite to such a radical degree.

Of course there is another group of people who also have a bunch of work to do, and that’s the hardware vendors. If Windows 8 is to be successful one would assume that the default for personal computer and laptop screens will need to change to be predominantly touch-enabled devices. While it is clearly stated in the video that the new UI will work just fine with a mouse and a keyboard, I for one am very skeptical about how WELL it will work in that mode! And of course the availability of the hardware is only a part of the story … we must also consider how long it will take companies to replace existing hardware with new touch-sensitive devices.

Now don’t get me wrong … I’m not suggesting for one minute that there will be a big rush to do so, and I’m absolutely suggesting that a major change of this type could take many years … but for some of us, with certain types of applications, in certain market places, adopting these new capabilities could offer significant rewards.

By the way, I’m not a betting man but I’d lay good money on the fact that there will be a setting to disable the new Windows 8 UI in favor of reverting to Windows 7’s Aero UI, and I’d also be comfortable predicting that many corporations will be doing just that. So again, don’t panic! While the new UI may make for a fabulous demo, and may be a fantastic way of interacting with photos and videos, and browsing the web, will it really provide a suitable platform for presenting business software to commercial users? Actually, in some cases the answer will be a resounding YES … but in other cases the more traditional approach to presenting applications will continue to be far more appropriate.

Of course in order for Synergy developers to be ready for Windows 8, Synergex must be ready first. I will be attending the Build Windows conference, as will three of my colleagues from the Synergy Development team. We’ll do our best to keep you informed about what we learn.

By the way, if you’re interested in keeping track of what’s going on with Windows 8 then a good place to start is Microsoft Development’s Building Windows 8 BLOG. The blog has some interesting articles, and already has several more videos discussing these new features.


Hosting WCF Services in an ASP.NET Web Application

By Steve Ives, Posted on July 1, 2011 at 3:39 pm

There are several ways that you can use Synergy/DE tools to expose WCF services, but regardless of which way you decide to create a service, the next decision you have to make is how to host it. By hosting a WCF service you expos the service and make it possible to use it from other applications. In this post I will introduce you to one way that WCF services may be hosted, via an ASP.NET web application and an IIS web server. In a later post I will show you how to host WCF services without this requirement for an IIS web server.

This is the third in a series of posts relating to the various ways in which Synergy developers can use of Windows Communication Foundation (WCF) when building their applications. The posts in the series are:

  1. Building Distributed Apps with Synergy/DE and WCF
  2. Exposing WCF Services using xfNetLink .NET
  3. Hosting WCF Services in an ASP.NET Web Application (this post)
  4. Exposing WCF Services using Synergy .NET Interop
  5. Self-Hosting WCF Services
  6. Exposing WCF services using Synergy .NET

 

A WCF service is simply a collection of one or more classes in an assembly, but the whole point of implementing a WCF service is to make those classes available to be used by other applications. And those applications will often be located on different networked systems from the service itself. So, in order for a WCF service to be useful, it needs to be “hosted” somewhere, and that somewhere needs to be available on a network.

There are three basic ways that WCF services can be hosted:

  1. Inside a Web application located on a Web server.
  2. Using Windows Process Activation Services (WAS). This mechanism was introduced in Windows Server 2008 and provides a mechanism for hosting WCF services without requiring a Web server.
  3. Services can be “self” hosted by some custom .NET application. For example, developers often host WCF services inside a Windows Service application.

In this post I will show you the basics of hosting a WCF service in an ASP.NET web application. In a future post I will go on to show how to self-host services.

Setting up basic hosting for a WCF service inside an ASP.NET Web application is very easy, but as Synergy .NET doesn’t have support for creating Web applications you’ll have to use another .NET language, either C# or VB.NET. However, don’t worry about that too much, because there won’t actually be any code in the Web application!

  • Start Visual Studio 2010 and create a new ASP.NET application:
    • From the menu, select File > New > Project.
    • Under Installed Templates, select Visual C# > Web > ASP.NET Empty Web Application.
    • Chose the name and location for your new Web application.
    • Click the OK button to create the new project.
  • Add a new WCF Service to the project:
    • From the menu, select Project > Add New Item.
    • Under Installed Templates, select Visual C# > Web > WCF Service.
    • Enter the name for your new service. The name will be part of the service endpoint URI that the client connects to, so pick something meaningful. For example, if your service allows orders to be placed then you might name the service something like OrderServices.svc.
    • Click the Add button to add the new service to the project.

You will notice that three files were added to the project:

image

In addition to the service (.svc) file that you named, you will see two C# source files. These files were added because Visual Studio provided all of the files that you would need in order to expose a new WCF service that would be manually coded in these files. But what we’re trying to do is host a WCF service that already exists in another .NET assembly.

  • Delete the two C# source files by right-clicking on each and selecting delete.

In order to expose a WCF service that exists in another assembly, the first thing we need to do is add a reference to that assembly, to make the classes it contains available within the new Web application.

  • From the menu select Project > Add Reference and then select Browse.
  • Locate and select the assembly containing your WCF service and add a reference to your project.
  • If the assembly you selected was created using xfNetLink .NET then you will also need to add a reference to the xfnlnet.dll assembly, as is usual when using xfNetLink .NET

You’ll need to know that namespace and class name of the WCF service in your assembly. If you can’t remember this that double-click on the assembly that you just referenced and then use Object Browser to drill into the assembly and figure out the names. All that remains is to “point” the service file at your WCF service class.

  • Double-click on the service (.svc) file to edit it. You should see something like this:

image

Edit the file as follows:

  • Change Language=”C#” to Language=”Synergy”.
  • Change Service=”…” to Service=”YourNamespace.YourWcfClass” (obviously replacing YourNamespace and YourWcfClass with the namespace and class name of your WCF service).
  • Remove the CodeBehind=”…” item … there is no code-behind, the code is all in the other assembly.
  • Save the file.

So you should now have something like this:

image

If your service is based on an assembly created using xfNetLink .NET then you have one final configuration step to perform. You need to tell xfNetLink .NET how to connect to xfServerPlus. You can do this by using the Synergy xfNetLink .NET Configuration Utility (look in the Windows Start Menu) to edit the new web applications Web.config file. If your xfServerPlus service is not on the same machine as your new web application then you must specify a host name or IP address, and if xfServerPlus is not using the default port (2356) then you must also specify a port number. When you’re done, the Web.config file should contain a section like this:

image

That’s it, you’re done. You should now have a working WCF service!

  • To see if the service has really been hosted, right-click on the service (.svc) file and select View In Browser.

You should see the service home page, which will look something like this:

image

If you see this page then your service is up and running. By the way, the URI in your browsers address window is the URI that you would use to add a “Service Reference” to the service in a client application … but we’ll get on to that in a later post.

Of course, all we have actually done here is set up a web application to host a WCF service, but we’re using Visual Studio’s built in development web server (Cassini) to actually host the service. If you were doing this for real then you’d need to deploy your new web application onto a “real” IIS web server.

We’re not done with the subject of hosting WCF services; in fact we’ve only really scratched the surface. One step at a time!

In my next post in this series I will show you how to Expose a WCF services using Synergy .NET Interop.


Exposing WCF Services using xfNetLink .NET

By Steve Ives, Posted on at 1:40 pm

Following a recent enhancement to the product in Synergy 9.5.1, developers can now use xfNetLink .NET to create and expose Windows Communication Foundation (WCF) services. In this post I will describe how to do so.

This is the second in a series of posts relating to the various ways in which Synergy developers can use of Windows Communication Foundation (WCF) when building their applications. The posts in the series are:

  1. Building Distributed Apps with Synergy/DE and WCF
  2. Exposing WCF Services using xfNetLink .NET (this post)
  3. Hosting WCF Services in an ASP.NET Web Application
  4. Exposing WCF Services using Synergy .NET Interop
  5. Self-Hosting WCF Services
  6. Exposing WCF services using Synergy .NET

 

The basic approach is pretty easy; in fact it’s very easy. In 9.5.1 we added a new -w command line switch to the gencs utility, and when you use the new switch you wind up with a WCF service. I told you it was easy!

So, what changes when you use the gencs –w switch? Well, the first thing that changes are the procedural classes that are generated, the ones that correspond to your interfaces and methods in your method catalog, change in the following ways:

  1. Three new namespaces (System.Runtime.Serialization, System.ServiceModel and System.Collections.Generic) are imported.
  2. The class is decorated with the ServiceContract attribute. This identifies the class as providing methods which can be exposed via WCF.
  3. Methods in the class are decorated with the OperationContract attribute. This identifies the individual methods as being part of the service contract exposed by the class, making the methods callable via WCF.
  4. If any methods have collection parameters, the data type of those parameters is changed from System.Collections.ArrayList to System.Collections.Generic.List. Changing the collection data type is not strictly necessary in order to use WCF, but results in a more strongly prototyped environment which is easier to use, and offers more benefits to developers in terms of increased IntelliSense, etc.

The next thing that changes are any data classes, the ones that correspond to the repository structures that are exposed by the parameters of your methods, that are generated. These data classes change in the following ways:

  1. Two new namespaces are imported. These namespaces are System.Runtime.Serialization and System.ServiceModel.
  2. Each data class (which corresponds to one of your repository structures) that is generated is decorated with the DataContract attribute. This identifies the data class as a class which can be used in conjunction with a WCF service, and which can be serialized for transmission over the wire.
  3. Each public property (which corresponds to a field in the structure) is decorated with the DataMemeber attribute. This attribute identifies each property within the class as one which will be serialized, and as a result will be visible to client applications which use the WCF service.

By the way, if you use a Workbench “.NET Component Project” to create your xfNetLink .NET assemblies then there isn’t currently an option in the component information dialog to cause the new –w switch to be used. So, for the time being, what you can do is add the switch to the Workbench “Generate C# Classes” tool command line. To do this you would go into project properties for the component project, go to the Tools tab, select the “Generate C# Classes” tool, then add the –w at the end of the command line, like this:

image

We’ll be adding a new checkbox to the component information dialog in 9.5.3 later this year.

By the way, by using the gencs –w switch you make it possible to use the resulting classes as a WCF service, but you don’t have to do so … you can continue to use the classes as a regular xfNetLink .NET assembly also. Why would you want to do that? Well, I sometimes use gencs –w just to turn my collection parameters into generic lists!

I have submitted a working example to the Synergy/DE CodeExchange, contained within the zip file called ClientServerExamples.zip. Within the example, the following folders are relevant to exposing and consuming a WCF Service using xfNetLink .NET:

Folder / Project

Description

xfServerPlus

Contains the Workbench development environment for xfServerPlus and the exposed Synergy methods. If you wish to actually execute the examples then you must follow the setup instructions in the readme.txt file.

xfNetLink_wcf

Contains the Workbench project used to create the xfNetLink .NET client assembly with the WCF attributes.

3_xfpl_xfnl_wcf_service

Contains the Visual Studio 2010 solution containing an ASP.NET web application used to host the WCF service, as well as three example client applications, written in Synergy .NET, C# and VB.

So, the gencs –w command line switch you make it possible to use the resulting classes to directly expose a WCF service, but there is still the matter of how to “host” the service in order to make it accessible to remote client applications, and that’s what I will begin to address in my next posting.


Lights, Camera, Action!

By Richard Morris, Posted on June 16, 2011 at 3:04 am

Now, thinking that once the Synergex Success Partner Conference (http://spc.synergex.com) is over, and we are all sat basking in the glory of the survey results (thanks to everyone who filled them in – the cheques are in the post!), sipping alcohol-free Pina Colada’s, you couldn’t be further from the truth.

Once the conference is over, that’s when the real work begins.  One of the first tasks if to begin the planning for next year’s conference – honestly.  It takes a full twelve months to plan, organise and deliver the SPC.  Reading the conference surveys helps us to first decide where to hold the conference.  Sometimes suggestions like “Somewhere sunny, but don’t tell the boss!” are not the most helpful.  Based on the feedback we receive we can also begin to sketch out a proposed agenda.  The agenda is also heavily influenced by future  developments which introduce new features and capabilities within the language – and there are some cool features in the pipeline so keep an eye on future blogs.

But before we can start next year’s planning, we need to complete the final tasks of this year’s conference, and that’s getting all the available information to everyone who attended.
The session slides have been posted on the Synergex web site.  All code samples are on the Synergex Code Exchange, and based on feedback from the Chicago conference I’ve created  videos for each of my conference presentations. So, light the lights check the sound levels and get the clapper board ready…

If you want to re-visit the User Interface opportunities presentation you can see a 20 minute video at

http://www.synergyde.com/services/education/product_video.aspx?video=ui_opportunities.

This video shows the evolution of a simple Synergy cell based program from the OpenVMS/UNIX cell based environment through the UI Toolkit, Windows and WPF, to a Native Synergy.NET desktop application.  The same Synergy logic is then utilised in a Silverlight Browser based client and finally a Windows Phone 7 app!

Giving your User Interface a “New Lick of Paint” is possible with Synergy and WPF.  There are two presentations on this subject, and really need to be viewed in order.  The first is “What, Why and How of MVVM” (http://www.synergyde.com/services/education/product_video.aspx?video=what_why_and_how_of_mvvm).  This video takes you through the basics of the Model, View, ViewModel design pattern and how to implement it within your existing Synergy applications.

The second video is called “Building Targeted UI’s” (http://www.synergyde.com/services/education/product_video.aspx?video=building_targeted_uis).  This builds on the first MVVM video and demonstrates what you can begin to achieve with your new Synergy based WPF applications.

My final SPC 2011 session was titled “Cool Framework Features”.  During the presentation I demonstrated some simple ways to enhance your existing applications with .NET
framework features, and there are two videos to show you how.  The “Cool Framework Features – PDF” (http://www.synergyde.com/services/education/product_video.aspx?video=cool_framework_features__pdf) video shows you how to fully automate the production of PDF documents using a printer driver called Win2PDF, the Synergy Windows Printing API, and the Synergy .NET API to set Windows Registry settings.

A second video from this session is called “Cool Framework Feature – XML” (http://www.synergyde.com/services/education/product_video.aspx?video=cool_framework_features__xml).  This video shows how to implement the .NET Validating XML parser into your Synergy applications to load, parse and
validate an XML document given a XML schema.

Take a look at the videos and let me know what you think.  If there are any subjects you’d like to see covered either at the SPC or even in video format please let me know.


Visual Studio 2008 SP1 Hangs After Office Upgrade

By Steve Ives, Posted on July 22, 2010 at 5:55 pm

Just incase you run into the same issue…

This week I had to revert back to using Visual Studio 2008 while working on a customer project, and I pretty quickly found that I had a problem. I was working on an ASP.NET web project, and found that each time I opened a web page for editing, Visual Studio would appear to hang. Clicking anywhere on the Visual Studio window resulted in the ubiquitous Windows “beep” sound.

On researching the problem in the “Universal Documentation System” (Google) I quickly found that I was not alone in my frustrations … in fact it seems like this is a common issue right now.

Turns out that the problem is related to the fact that I recently updated from Office 2007 to Office 2010. I guess Visual Studio 2008 uses some components from Office 2007 when editing HTML and ASPX pages, and I guess that component got screwed up by the Office 2010 upgrade. If you encounter this problem you will likely find that when Visual Studio 2008 hangs it has started a SETUP.EXE process, but that process never seems to complete. Apparently it’s attempting to do a repair of the “Microsoft Visual Studio Web Authoring Component”, but for some reason can’t.

The solution seems to be to manually run the setup program and select “Repair”. On my system the setup program was C:Program Files (x86)Common Filesmicrosoft sharedOFFICE12Office Setup ControllerSetup.exe. My system runs a 64-bit O/S … if you’re using a 32-bit O/S you’ll presumably just need to drop the (x86) part.

The repair took about two or three minutes, and low and behold I have my Visual Studio 2008 installation working just fine again!


Another TechEd Sticky Note

By synergexadmin, Posted on June 10, 2010 at 11:58 pm

The other night, I discovered the way to beat the heat while here in New Orleans. It’s a fruity little concoction known as the Hurricane, and while it doesn’t actually affect the climate around you, it sure makes feeling hot and sticky a lot more enjoyable. I’m also pretty sure how it got its namesake: in the morning, you find yourself trying to reconstruct the previous 12 hours of your life by putting together the pieces and fragments of your memory.

TechEd 2010 draws to a close this evening, and though it’s been increasingly difficult to find sessions that seem pertinent to we Synergexians, it’s still been a worthwhile experience.
I’ve learned a lot just by watching presenters step through the build of a Silverlight UI using Microsoft Expression, or show off the latest features of Visual Studio 2010 and how it can be used to quickly create a web app, or walk through the use of new simplified Windows Communication Foundation 4 features.I’ve even filled in the holes in my schedule with sessions on interesting (to me) topics, such as IPv6, trends in cybercrime, and hacker techniques.

Which all brings me to the point of this little blog entry: It seems to me that the value of conferences lies not in the number of sessions that directly apply to you, but in the quantity and quality of the little tidbits you pick up each day. It’s in the discussions you have with other developers and like-minded individuals – whether they take place while sitting down over a cup of coffee, or simply during a quick ride in the elevator. It’s in the creative ideas that spring up when you see a clever implementation and wonder if you can apply the same techniques to an unrelated solution of your own. It’s in the tips, tricks and techniques that you pick up, which will not only save you hours, days, and even weeks of effort in the year ahead, but which can also be shared with the rest of your team to make them more productive as well.

Just a sales pitch for SPC2010? Perhaps…but that wasn't the intent. After all, this is my blog, and with it I get to share helpful experiences from my time “out in the field.” If writing about it all means I’ll get to see more of you when we set up shop in October at the Citizen Hotel, then so much the better. But in the end, my little revelation about the value of coming to TechEd – even with so much focus on technologies that I can’t use – is helping me to sit back and enjoy this final day of the conference, secure in the knowledge that I’m going to be learning something interesting at every turn. And isn’t that what attending the conference is all about?

That, and the Hurricanes, of course…


Live from TechED, Updated!

By Richard Morris, Posted on November 13, 2009 at 11:37 pm

The end of TechED is nigh, and to be honest I'm sort of happy.  It's been an intense week of presentations, workshops and in depth discussions with fellow developers, Microsoft techies and the guys at all the UI control vendors.  I know what our customers mean now after they have attended our SPC: info overload followed closely by brain fade!

As the vendors begin to pack up, Tod and myself unselfishly offered to burden ourselves by offering to help lessen the vendors packing toils by relieving them of any spare goodie-bag items they may have.  It's tough at times!  As we toil, we notice 6998 TechHeads filing off to catch a train that carries at maximum a few hundred people.  They must have all missed the multi-threading, delayed processing and smooth streaming sessions.  We on the other hand thread our way, via a routed URL, through the streets of Berlin, testing our interop skills with the locals.

On a more technical level this week has shown just how determined Microsoft are to be market leaders, and with the tools on show this week it's difficult to see why they shouldn't be.  And the best news of all?  Synergex, with our current capabilities to integrate with .NET and our emerging integration with Visual Studio, we'll be able to take full advantage of these latest technologies.  The future is looking good if you develop with Synergy.


Don't miss a post!

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Recent Posts Tag Cloud Archives