I use this blog to post ideas and experiences about software development with the goal to help all the technology communities around the world.

11/30/13

This is a simple snippet to show a simple way to display the
current assembly version of a WCF Web Service.
We first need a helper class with a method that looks as follows: (class
is excluded for brevity)

publicstaticstring GetVersion()

{

string version = string.Empty;

var assembly =
System.Reflection.Assembly.GetExecutingAssembly();

if (assembly != null)

{

version =
assembly.GetName().Version.ToString();

}

return version;

}

We now need to add a Web method to our web service that we can
call to return the version number. I often like to add a Ping or Version web method
to the web services to test basic client connectivity. The method just needs to call the helper class and return the string with the version information
as follows:

publicString Ping()

{

string version = RequestHelper.GetVersion();

return version;

}

When testing this web service, you can call this method to verify
what current version is deployed.