visual studio:调试器在部署后不启动应用程序

时间:2015-11-30 17:06:50

标签: c# visual-studio debugging deployment visual-studio-2015

我的问题是,在我调试程序后,它不会加载我的应用程序,这是我唯一能看到的内容:http://prntscr.com/98oybj 我无法在谷歌上找到它,令人非常沮丧。 在构建时我没有得到任何错误或什么,但应用程序没有启动。 即使等待它仍然没有启动应用程序。甚至认为VS说“部署成功”'

这真的很烦人,这也发生在其他项目中。顺便说一句,我没有自己制作这个代码,它来自于书:microsoft visual c#step by step 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;
    }
}

1 个答案:

答案 0 :(得分:0)

确保在Visual Studio中检查错误列表和输出窗口(均在“视图”菜单下)。然后在此处报告任何错误消息。抱歉,我在屏幕截图中看不到任何内容,而且我没有足够的权限对​​此进行评论。