2

调用第一个方法时,应调用一次静态构造函数。每次调用方法时都会调用我的构造函数。任何想法为什么会这样?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace SimpleWS
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    public class WebService1 : System.Web.Services.WebService
    {
        static WebService1()
        {
            //initialize
            //write to log file
        }

        [WebMethod]
        public string test()
        {
            return "0";
        }
    }
}
4

0 回答 0