Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 试图通过用C编写的Windows服务在ThingWorx上上载扩展#_C#_Windows_Service_Thingworx - Fatal编程技术网

C# 试图通过用C编写的Windows服务在ThingWorx上上载扩展#

C# 试图通过用C编写的Windows服务在ThingWorx上上载扩展#,c#,windows,service,thingworx,C#,Windows,Service,Thingworx,我正在使用ThingWorx的ExtensionPackageUploader通过C#上传扩展。当我从VisualStudio运行它时,它可以工作,但在将它作为Windows服务安装后,它似乎不再工作了 public void UploadExtensionToThingWorx() { string endpoint=“/Thingworx/ExtensionPackageUploader”; string url=“http://”+serverAddress+:“+serverPort+e

我正在使用ThingWorx的ExtensionPackageUploader通过C#上传扩展。当我从VisualStudio运行它时,它可以工作,但在将它作为Windows服务安装后,它似乎不再工作了

public void UploadExtensionToThingWorx()
{
string endpoint=“/Thingworx/ExtensionPackageUploader”;
string url=“http://”+serverAddress+:“+serverPort+endpoint;
string filePath=Path.Combine(ExecutionDirectory,ExtensionFileName);
字节[]fileContent=ReadFile(文件路径);
string formDataBoundary=string.Format(“------------{0:N}”,Guid.NewGuid());
string contentType=“多部分/表单数据;边界=“+formDataBoundary;
byte[]formData=GetMultipartFormData(formDataBoundary、ExtensionFileName、fileContent);
HttpWebRequest-request=WebRequest.Create(url)为HttpWebRequest;
request.Method=“POST”;
request.ContentType=ContentType;
request.CookieContainer=新的CookieContainer();
request.ContentLength=formData.Length;
添加(“AppKey”,applicationKey);
request.Headers.Add(“X-XSRF-TOKEN”、“TWX-XSRF-TOKEN-VALUE”);
使用(Stream requestStream=request.GetRequestStream())
{
Write(formData,0,formData.Length);
requestStream.Close();
}
}

当我直接从Visual studio运行代码时,代码正在运行。

请在问题中添加相关的源代码和所有错误/日志消息。请重新编写问题文本。