HttpContext.Current.Server null

后端 未结 3 1501
别那么骄傲
别那么骄傲 2020-12-07 02:15

I have a windows service which is using a method from a class library with same asp.net solution. in class library, I have a method with following line:

 re         


        
3条回答
  •  孤城傲影
    2020-12-07 02:33

    HttpContext.Current is returning null because your Windows Service is not running under the umbrella of IIS or some other web server provder.

    However, you can find the executing path of your service using reflection:

    System.Reflection.Assembly.GetExecutingAssembly().Location
    

    ^ should return the path of the executing service..

提交回复
热议问题