总是提示 :“远程服务器返回了错误: 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
...全文
293 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
starrycheng 2012-08-15
  • 打赏
  • 举报
回复
补齐。。。
starrycheng 2012-08-11
  • 打赏
  • 举报
回复
“远程服务器返回了错误: NotFound。” ,这是什么错误类型,怎样引发的???
内容概要:本文提出了一种基于加权稀疏矩阵恢复与加速交替方向乘子法(ADMM)的单通道盲解混响算法,并提供了完整的Matlab代码实现。该方法旨在从仅有的单路接收信号中有效分离出原始声源信号,克服传统多通道方法对硬件的依赖。核心技术结合了信号在时频域的稀疏性先验,通过构建加权机制以增强稀疏矩阵恢复的准确性,并引入加速ADMM算法来优化求解过程,显著提升了算法的收敛速度与计算效率。该算法特别适用于麦克风阵列受限或无法部署的复杂声学环境,能够有效抑制混响干扰,从而显著提升语音信号的清晰度与后续语音识别系统的性能。; 适合人群:具备扎实的数字信号处理、凸优化理论及稀疏表示基础,从事音频信号处理、语音增强、盲源分离或相关领域研究与开发工作的研究生、科研人员及工程技术人员。; 使用场景及目标:①解决单麦克风场景下的语音混响去除难题,提升语音通信质量;②应用于智能助听器、车载语音系统、远程视频会议、人机交互等存在严重混响的实际应用场景;③为盲解卷积、稀疏信号恢复等领域的研究提供一种高效的算法实现范例与优化思路。; 阅读建议:建议读者在深入理解信号稀疏性、ADMM优化框架等理论基础上,结合所提供的Matlab代码进行实践,重点分析加权策略的设计原理及其对恢复性能的影响,并通过调整正则化参数、权重因子等关键变量,探究其在不同混响强度和噪声条件下的鲁棒性与泛化能力。

8,757

社区成员

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

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