2015-11-30 152 views
1

我的問題是,我調試我的程序後,它不會加載我的應用程序,這是我看到的唯一的東西:http://prntscr.com/98oybj 我不能找到它在谷歌,使非常沮喪。 構建應用程序時,我沒有收到任何錯誤或錯誤,但應用程序無法啓動。 即使在等待它仍然不啓動應用程序。甚至認爲VS說''部署成功''visual studio:調試器沒有啓動應用程序後部署

這真的很煩人,這也發生在其他項目。順便說一句,我沒有自己做這個代碼,它是從書:微軟的Visual C#步步2013年

下面是代碼:

public sealed partial class GraphWindow : Page 
{ 
    // Reduce pixelWidth and pixelHeight if there is insufficient memory available 
    private int pixelWidth = 12000; 
    private int pixelHeight = 7500; 

    private WriteableBitmap graphBitmap = null; 
    private int bytesPerPixel = 4; 
    private byte[] data; 

    private byte redValue, greenValue, blueValue; 
    private CancellationTokenSource tokenSource = null; 

    public GraphWindow() 
    { 
     this.InitializeComponent(); 

     int dataSize = bytesPerPixel * pixelWidth * pixelHeight; 
     data = new byte[dataSize]; 

     graphBitmap = new WriteableBitmap(pixelWidth, pixelHeight); 
    } 

    private void cancelButton_Click(object sender, RoutedEventArgs e) 
    { 
     if (tokenSource != null) 
     { 
      tokenSource.Cancel(); 
     } 
    } 

    private void plotButton_Click(object sender, RoutedEventArgs e) 
    { 
     Random rand = new Random(); 
     redValue = (byte)rand.Next(0xFF); 
     greenValue = (byte)rand.Next(0xFF); 
     blueValue = (byte)rand.Next(0xFF); 

     tokenSource = new CancellationTokenSource(); 
     CancellationToken token = tokenSource.Token; 

     Stopwatch watch = Stopwatch.StartNew(); 

     try 
     { 
      generateGraphData(data, 0, pixelWidth/2, token); 
      duration.Text = string.Format("Duration (ms): {0}", watch.ElapsedMilliseconds); 
     } 

     catch (OperationCanceledException oce) 
     { 
      duration.Text = oce.Message; 
     } 

     Stream pixelStream = graphBitmap.PixelBuffer.AsStream(); 
     pixelStream.Seek(0, SeekOrigin.Begin); 
     pixelStream.Write(data, 0, data.Length); 
     graphBitmap.Invalidate(); 
     graphImage.Source = graphBitmap; 
    } 

    private void generateGraphData(byte[] data, int partitionStart, int partitionEnd, CancellationToken token) 
    { 
     int a = pixelWidth/2; 
     int b = a * a; 
     int c = pixelHeight/2; 

     for (int x = partitionStart; x < partitionEnd; x++) 
     { 
      int s = x * x; 
      double p = Math.Sqrt(b - s); 
      for (double i = -p; i < p; i += 3) 
      { 
       token.ThrowIfCancellationRequested(); 

       double r = Math.Sqrt(s + i * i)/a; 
       double q = (r - 1) * Math.Sin(24 * r); 
       double y = i/3 + (q * c); 
       plotXY(data, (int)(-x + (pixelWidth/2)), (int)(y + (pixelHeight/2))); 
       plotXY(data, (int)(x + (pixelWidth/2)), (int)(y + (pixelHeight/2))); 
      } 
     } 
    } 

    private void plotXY(byte[] data, int x, int y) 
    { 
     int pixelIndex = (x + y * pixelWidth) * bytesPerPixel; 
     data[pixelIndex] = blueValue; 
     data[pixelIndex + 1] = greenValue; 
     data[pixelIndex + 2] = redValue; 
     data[pixelIndex + 3] = 0xBF; 
    } 
} 
+0

你是如何部署應用程序? – stuartd

+0

我對此很新,所以我儘量給你提供儘可能多的信息。它調試爲winrt(通用Windows 8.1(商店)應用程序開發)。雖然沒有改變任何設置,所以它使用標準的調試器爲win 8.1應用程序。 – wouterrobot

回答

0

請務必檢查錯誤列表和輸出窗口中Visual Studio(在View菜單下)。然後在這裏報告任何錯誤消息。對不起,我看不到任何你的屏幕截圖,我沒有足夠的權利來發表評論。

+0

沒有錯誤,也沒有警告。這是我在visual studio調試時看到的截圖。通常情況下,應用程序將在該屏幕後啓動,但它仍然卡住?這是xaml窗口顯示的內容:http://prntscr.com/994wqf。這是我得到的:http://prntscr.com/994x0r。停止調試後,屏幕保持打開狀態,但實際上它應該像每個應用程序一樣關閉。 – wouterrobot

相關問題