是否可以在Web服務描述中顯示修訂/內部版本號? 我希望用戶在轉到web服務的url時查看當前正在運行的版本。C#在web服務描述中顯示修訂/內部版本號?
Ex。
[WebService(Namespace = "http://webservice.mydomain.com/", Name = "webservice for multimedia devices", Description = "Last build: **xxxxx**")]
我要動態地得到它,如果可能的(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()
)
我也試過這個(建議見下文)。這得到了描述,但它在向客戶端顯示web服務之前無法更新它。
var t = typeof(webClient);
var att = (WebServiceAttribute)t.GetCustomAttributes(typeof(WebServiceAttribute), true)[0];
att.Description = "Current running version: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
似乎不起作用。我添加了這個:var t = typeof(webClient); var att =(WebServiceAttribute)t.GetCustomAttributes(typeof(WebServiceAttribute),false)[0]; att.Description =「當前正在運行的版本:」+ System.Reflection.Assembly.GetExecutingAssembly()。GetName()。Version; – Patrick
這得到了描述,但沒有更新它。我忘了提及我使用.NET 3.5而不是4. – Patrick
您是否嘗試在自定義ServiceHostFactory中添加此代碼(http://msdn.microsoft.com/zh-cn/library/system.servicemodel.activation.servicehostfactory。 ASPX)?我認爲這應該工作。 – Peter