-1

我正在使用的 Web 服务返回了 Web 异常。从 Silverlight 应用程序调用服务。基本上我正在尝试将 eps 文件转换为 png 。在本地主机上一切正常,但是当我部署在 Web 服务器上时,我收到了这个错误。Silverlight 代码是——

  private void btnUploadImage_Click(object sender, RoutedEventArgs e)
        {
            string fileextn = string.Empty;
            OpenFileDialog openDialog = new OpenFileDialog();
            if (openDialog.ShowDialog() == true)
            {
                try
                {
                    string fileExtension = openDialog.File.Extension.ToString();
                    if (fileExtension.Contains("jpeg") || fileExtension.Contains("jpg") || fileExtension.Contains("png") || fileExtension.Contains("tif") || fileExtension.Contains("tiff") || fileExtension.Contains("bmp") || fileExtension.Contains("gif"))
                    {

                        using (Stream stream = openDialog.File.OpenRead())
                        {
                            HtmlPage.Window.Invoke("showProcessingAndBlockUI");
                            // Don't allow really big files (more than 2 MB).
                            if (stream.Length < 5 * 1024 * 1025)
                            {
                                MemoryStream tempStream = new MemoryStream();
                                byte[] data = new byte[stream.Length];
                                stream.Position = 0;
                                stream.Read(data, 0, (int)stream.Length);
                                tempStream.Write(data, 0, (int)stream.Length);
                                stream.Close();
                                ProductConfiguratorServiceClient pcs = new ProductConfiguratorServiceClient();
                                string virtualpath = HelperClass.GetVirtual();
                                pcs.Endpoint.Address = new System.ServiceModel.EndpointAddress(virtualpath + "/Services/ProductConfiguratorService.svc/basic");
                                pcs.GetFormattedImageCompleted += new EventHandler<GetFormattedImageCompletedEventArgs>(pcs_GetFormattedImageCompleted);
                                pcs.GetFormattedImageAsync(data);
                                pcs.CloseAsync();
                                tempStream.Close();
                            }
                            else
                            {
                                MessageBox.Show("Files must be less than 5 MB.");
                            }
                        }
                    }
                    else if (openDialog.File.Extension.Contains("eps"))
                    {
                        HtmlPage.Window.Invoke("showProcessingAndBlockUI");
                        using (Stream stream = openDialog.File.OpenRead())
                        {
                            if (stream.Length < 5 * 1024 * 1025)
                            {
                                MemoryStream tempStream = new MemoryStream();
                                byte[] data = new byte[stream.Length];
                                stream.Position = 0;
                                stream.Read(data, 0, (int)stream.Length);
                                tempStream.Write(data, 0, (int)stream.Length);
                                stream.Close();
                                ProductConfiguratorServiceClient pcs = new ProductConfiguratorServiceClient();
                                string virtualpath = HelperClass.GetVirtual();
                                pcs.Endpoint.Address = new System.ServiceModel.EndpointAddress(virtualpath +                                                                                              "/Services/ProductConfiguratorService.svc/basic");
                                pcs.GetEpsFileIntoPngCompleted += new EventHandler<GetEpsFileIntoPngCompletedEventArgs>(pcs_GetEpsFileIntoPngCompleted);
                                pcs.GetEpsFileIntoPngAsync(data);
                                tempStream.Close();
                            }
                            else
                            {
                                MessageBox.Show("Files must be less than 5 MB.");
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please Check the Image Format.");
                    }
                }
                catch (Exception)
                {
                    HtmlPage.Window.Invoke("hideBlockUI");
                    MessageBox.Show("Somr Error Occured, Please Try Again Later .");
                }
            }

        }

        void pcs_GetEpsFileIntoPngCompleted(object sender, GetEpsFileIntoPngCompletedEventArgs e)
        {
                busi.CurrentlySelectedOverlayImage.UploadedImageStream = e.Result;
                busi.CurrentlySelectedOverlayImage.ImageFileType = "png";
                RefreshStatus();
                busi.CurrentlySelectedOverlayImageChanged = true;
                HtmlPage.Window.Invoke("hideBlockUI");
        }

        void pcs_GetFormattedImageCompleted(object sender, GetFormattedImageCompletedEventArgs e)
        {
            try
            {
                if (e.Error != null)
                {
                    MessageBox.Show(e.Error.ToString());
                }
                else
                {
                    busi.CurrentlySelectedOverlayImage.UploadedImageStream = e.Result;
                    busi.CurrentlySelectedOverlayImage.ImageFileType = "jpeg";
                    RefreshStatus();
                    busi.CurrentlySelectedOverlayImageChanged = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            //throw new NotImplementedException();
        }

错误在System.Net.Browser.BrowserHttpWebRequest

请问这是什么问题?

4

1 回答 1

0

这可能与这条线有关。

pcs.Endpoint.Address = new System.ServiceModel.EndpointAddress(virtualpath + 

你错过了它的其余部分。很确定这是一个编译错误。

因此,要么这个错误被吃掉并且通用的错误正在弹出,要么你还有其他一些问题。

于 2013-06-28T17:45:30.577 回答