总是提示 :“远程服务器返回了错误: NotFound。” , Why???

starryyujianshu 2012-08-11 09:11:03
一个PDF到处方法,导出时总是发生错误。可以从http://silverlightpdf.codeplex.com/获得。

下载的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
...全文
309 2 打赏 收藏 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
starrycheng 2012-08-15
  • 打赏
  • 举报
回复
补齐。。。
starrycheng 2012-08-11
  • 打赏
  • 举报
回复
“远程服务器返回了错误: NotFound。” ,这是什么错误类型,怎样引发的???
内容概要:本文介绍了一个基于Python的无人机三维路径规划项目,采用差分进化算法(DE)在复杂三维环境中自动生成安全、高效的飞行路径。项目构建了包含起点、终点和多个长方体障碍物的三维空间模型,通过将路径编码为中间航点向量,利用差分进化进行全局优化。适应度函数综合考量路径长度、碰撞惩罚、安全距离、转弯代价、爬升能耗和高度约束,确保生成的路径在安全性、平滑性和可行性之间取得平衡。优化后还引入路径简化机制,删除冗余航点并检测直连安全性,以减少航点数量并提升可执行性。程序输出包括三维路径图、障碍物可视化、适应度收敛曲线及各项性能指标,支持后续扩展至真实地图、地形模型和动力学仿真。; 适合人群:具备Python编程基础,熟悉NumPy、matplotlib等库,从事无人机、智能优化、路径规划相关研究或开发的科研人员、研究生及工程师(工作年限1-3年或有相关项目经验者); 使用场景及目标:①解决城市、山区、工业区等复杂三维环境下的无人机避障路径规划问题;②学习差分进化算法在连续空间优化中的应用;③为低空物流、应急救援、巡检监测等实际场景提供算法原型与二次开发基础; 阅读建议:建议结合提供的完整代码与可视化结果进行实践,重点关注环境建模、适应度函数设计、差分进化实现与路径后处理逻辑,可通过调整参数(如种群规模、权重系数)观察优化效果变化,深入理解多目标权衡与算法调参策略。

8,757

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧