views:

181

answers:

4

Hello,

Can anyone suggest a way of getting version information into a Web Service. (VB.NET)

I would like to dynamically use the assembly version in the title or description, but the attributes require constants.

Is manually writing the version info as a string the only way of displaying the information on the .asmx page?

Thanks

A: 

You need to pick a type in your assembly and then do the following:

typeof(Some.Object.In.My.Assembly).Assembly.GetName().Version;
Nick Berardi
A: 

via reflection you can get the Assembly object which contains the assembly version.

Sven Hecht
A: 

Yeah, attributes cannot have anything but constants in them, so you cannot use reflection to get the version number. The WebServiceAttribute class is sealed too, so you cannot inherit it and do what you want from there.

A solution might be to use some kind of placeholder text as the Name, and set up an MsBuild task to replace it with the version number when building the project.

Fredrik Kalseth
A: 

Hello,

I perhaps wasn't clear enough in my question, my bad, I know how to get the assembly version using

System.Reflection.Assembly.GetExecutingAssembly.GetName.Version.ToString

But placing this in the Web Service Description attribute causes a compile error because the attribute only accepts constants, which the above isn't.

I was looking for ways around this.

David A Gibson