总是提示 :“远程服务器返回了错误: NotFound。” , Why???
下载的Demo中是没有问题的,但是引用到我的项目中就会出现问题。
#region PDF导出
private void PDFToPrint(Grid chart)
{
SaveFileDialog fsd = new SaveFileDialog();
fsd.Filter = "PDF (*.pdf)|*.pdf|*PNG (*.png)|*.png";
if (fsd.ShowDialog() == true)
{
//Create WriteableBitmap object which is what is being exported.
WriteableBitmap wBitmap = new WriteableBitmap(chart, null);
int hgt = wBitmap.PixelHeight;
int wdth = wBitmap.PixelWidth;
//Create EditableImage oblect and iterrate through WriteableBitmap pixels to set EditableImage pixels
EditableImage ei = new EditableImage(wdth, hgt);
for (int y = 0; y < hgt; y++)
{
for (int x = 0; x < wdth; x++)
{
int pixel = wBitmap.Pixels[((y * wdth) + x)];
ei.SetPixel(x, y, (byte)((pixel >> 16) & 0xff), (byte)((pixel >> 8) & 0xff), (byte)(pixel & 0xff), (byte)((pixel >> 24) & 0xff));
}
}
//Get the stream from the encoder and create byte array from it
System.IO.Stream pngStream = ei.GetStream();
printBuffer = new Byte[pngStream.Length];
pngStream.Read(printBuffer, 0, printBuffer.Length);
switch (fsd.FilterIndex)
{
case 1:
HttpWebRequest hwr = (HttpWebRequest)HttpWebRequest.Create(new Uri(Application.Current.Host.Source.ToString().Substring(0, Application.Current.Host.Source.ToString().LastIndexOf("/")) + "/Png2Pdf.ashx"));
hwr.Method = "POST";
printStream = fsd.OpenFile();
printSyncContext = System.Threading.SynchronizationContext.Current;
hwr.BeginGetRequestStream(new AsyncCallback(PrintStart), hwr);
break;
case 2:
//Save the PNG to local disk
System.IO.Stream fs = fsd.OpenFile();
fs.Write(printBuffer, 0, printBuffer.Length);
fs.Close();
MessageBox.Show("You PNG has been created.", "Export Complete", MessageBoxButton.OK);
break;
}
}
}
private void PrintStart(IAsyncResult asynchronousResult)
{
HttpWebRequest hwr = (HttpWebRequest)asynchronousResult.AsyncState;
System.IO.Stream stream = (System.IO.Stream)hwr.EndGetRequestStream(asynchronousResult);
stream.Write(printBuffer, 0, printBuffer.Length);
stream.Close();
hwr.BeginGetResponse(new AsyncCallback(PrintGetResponse), hwr);
}
private void PrintGetResponse(IAsyncResult asynchronousResult)
{
HttpWebRequest hwr = (HttpWebRequest)asynchronousResult.AsyncState;
WebResponse resp = hwr.EndGetResponse(asynchronousResult);
问题:
这里发生了错误,“远程服务器返回了错误: NotFound。”。 这是什么错误???为什么会发生???
System.IO.Stream respStream = resp.GetResponseStream();
Byte[] respBytes = new Byte[respStream.Length];
respStream.Read(respBytes, 0, respBytes.Length);
printSyncContext.Post(PrintMergeThreads, new HttpWebRequestData(hwr, respBytes));
}
private void PrintMergeThreads(object state)
{
HttpWebRequestData hwrd = (HttpWebRequestData)state;
printStream.Write(hwrd.Data, 0, hwrd.Data.Length);
printStream.Close();
printStream = null;
printSyncContext = null;
MessageBox.Show("Your PDF has been created.", "Export Complete", MessageBoxButton.OK);
}
#endregion
相关推荐
解决IIS 远程服务器返回错误: (404) 未找到
解决IIS 远程服务器返回错误: (404) 未找到,反复参照文档步骤操作测试可行
C# FTP,GetResponse(),远程服务器返回错误
FtpWebRequest类实现ftp功能的一般过程 1、创建一个FtpWebRequest对象,指向ftp服务器的uri 2、设置ftp的执行方法(上传,下载等) 3、给FtpWebRequest对象设置属性(是否支持ssl,是否使用二进制传输等) 4、设置登录验证(用户名,密码) 5、执行请求 6、接收相应流(如果需要的话) 7、如果没有打开的流,则关闭ftp请求 其中一些重要的属性如下: ·Credentials – 指定登录ftp服务器的用户名和密码。 ·KeepAlive – 指定连接是应该关闭还是在请求完成之后关闭,默认为true ·UseBinary – 指定文件传输的类型。有两
服务器远程连接提示由于协议错误,客户端无法连接到远程计算机
今天远程连接服务器的时候提示中断远程桌面连接 ————————— 由于协议错误,客户端无法连接到远程计算机。 请请重新连接到远程计算机。如果客户端依旧无法连接,请跟网络管理员联系。 用远程桌面连接服务器时报错:由于协议错误,会话将被中断。请重新连接到远程计算机。 本以为是服务器的一般性错误,以为重新启动一下服务器就能解决问题,于是让机房重启了一下服务器。可无论怎么试问题仍旧,再用其它电脑试连接,还是一样的问题,无奈只好让人去机房装了个pcAnywhere不甘心用PCA,毕竟WINDOWS自带的远程桌面使用起来还是方便许多,于是用PCA登录到服务器上仔细检查。 终于在在系统日志里发现错误:终端服
MOC.NotFound:加载正常可编辑页面以显示 404 错误的 Neos CMS 包
MOC.NotFound 介绍 Neos CMS 包,可加载正常的可编辑页面以显示 404 错误。 与 Neos 4.3 - 5.x 兼容 支持具有 URI 段和默认维度的空段的多个内容维度。 安装 composer require "moc/notfound:^4.0" 在站点的根目录中创建一个带有 URI 段“404”的页面。 如果将内容维度与 URI 段一起使用,请确保页面存在于所有上下文中或通过后备。 或者在Settings.yaml中Settings.yaml以下配置: MOC : NotFound : uriPathSegment : 404 注意:如果你覆盖了某个包的配置中的配置而不是全局的,你需要确保这个包是在这个包之后加载的。 为此,请将"moc/notfound": "*"到composer.json包的require部分。
can 远程帧和错误帧详解
can 总线的远程帧 错误帧详解,主要摘取网上的资源整理的。



