“ vshost32.exe已停止工作”;或“致命执行引擎错误”;在Visual Studio中 [英] "vshost32.exe has stopped working" OR "fatal execution engine error" in Visual Studio

查看:586
本文介绍了“ vshost32.exe已停止工作”;或“致命执行引擎错误”;在Visual Studio中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio中遇到一些奇怪的错误,找不到头或尾。我正在用C#编写一些后端,该后端与第三方API联系以检索数据。有问题的代码是一个单独的类,是较大解决方案的一部分,但一定是问题所在,因为不使用此类时不会发生遇到的错误。

I'm encountering some odd errors in Visual Studio and can't find head or tail. I'm coding some backend in C# which contacts a third party API to retrieve data. The code in question, a single class, is part of a larger solution, but must be the problem as the errors encountered does not occur when not using this class.

计算机设置:


  • Visual Studio 2013,更新4

  • Visual Studio 2013, update 4

Windows 10,预览版本10041

Windows 10, Preview Build 10041

遇到错误

昨天,应用程序在调试时开始出现异常现象。
我不记得确切的第一个错误,但这与坏错误类似。或损坏的内存。

Yesterday the application started behaving weird when debugging it. The first error I don't remember exactly, but it was something along the lines of "bad" or "corrupted memory".

在不更改程序的情况下,我也可能会遇到FatalExecutionEngineError异常,该异常将在尝试运行程序后立即抛出(它并没有使

Without altering the program, I could also encounter a FatalExecutionEngineError exception, which would be thrown immediately after trying to run the program (It didn't make it to the first breakpoint, which was on the first line in the Main entry of the program. Weird!

编辑:看起来像这样:


托管调试助手'FatalExecutionEngineError'在'PathRedacted\whatsfordinner\whatsfordinner\bin\Debug\whatsfordinner.vshost.exe'中检测到问题。

Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in 'PathRedacted\whatsfordinner\whatsfordinner\bin\Debug\whatsfordinner.vshost.exe'.

附加信息:运行时遇到致命错误。错误的地址是线程0x11ac上的0x613e4379,错误代码是0xc0000005。此错误可能是CLR中的错误或用户的不安全或不可验证的部分此错误的常见来源包括COM-interop或PInvoke的用户封送处理错误,这些错误可能会破坏堆栈。

Additional information: The runtime has encountered a fatal error. The address of the error was at 0x613e4379, on thread 0x11ac. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

最后,我重新启动了计算机从一切都很奇怪。问题解决到今天。

In the end I rebooted my computer since it was all very strange. Problem solved until today.

现在,我似乎根本无法运行该程序。运行该程序后,vshost32.exe崩溃。我没有任何错误消息或任何暗示问题所在的地方。

Now I can't seem to run the program at all; Upon running the program, vshost32.exe just crashes. I don't get any error messages or anything to hint at where the issue is.

疑难解答步骤


  1. 重新引导了我的计算机-不变,执行时vshost32.exe崩溃

  2. 注释了使用该类的两行-程序运行正常。

  3. 尝试以发布的形式启动程序。而不是调试。 -程序似乎运行正常,尽管我无法测试到最后。 (该课程尚未完全完成,并且我不想对有问题的API进行垃圾邮件处理)。

  4. 试图在另一台运行Windows 7和Visual Studio 2012的计算机上运行该程序。-程序似乎运行良好。

  1. Rebooted my computer - No change, vshost32.exe crashes upon execution
  2. Outcommented the two lines where the class in question was used - Program runs fine.
  3. Tried starting the program as "Release" rather than "Debug". - Program seems to run fine, although I can't test it to the end. (The class is not entirely done yet, and I don't want to spam the API in question)
  4. Tried running the program on another computer running Windows 7 and Visual Studio 2012. - Program seemed to run fine.

这时我很迷路。我对问题可能在哪里一无所知。不幸的是,源代码由近200行组成,但由于我不知道,我将其全部发布了。

At this point I'm pretty lost. I have little idea as to where the issue might be. The source code unfortunately consists of nearly 200 lines, but as I have no clue, I am posting it all.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Specialized;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
using System.Security.Cryptography;

using Newtonsoft.Json.Linq;
using Newtonsoft.Json;

namespace whatsfordinner {

public class eTilbudRetriever {
    
    //Web method names
    readonly String Get = "GET";
    readonly String Post = "POST";
    readonly String Update = "UPDATE";
    readonly String Delete = "DELETE";

    //Parameter identifiers
    readonly String ParamApiKey = "api_key";
    readonly String ParamLatitude = "r_lat";
    readonly String ParamLongitude = "r_lng";
    readonly String ParamRadius = "r_radius";
    readonly String ParamLimit = "limit";
    readonly String ParamOffset = "offset";

    //Parameter values
    String Latitude = "57.051188"; //Aalborg coordinates
    String Longitude = "9.922371";
    String Radius = "800000"; //Radius in meters (800km)
    String Limit = "48"; // Results per query

    //Custom header identifiers
    readonly String HeaderXToken = "X-Token";
    readonly String HeaderXSignature = "X-Signature";

    //Custom header values
    readonly String ContentType = "application/json";

    //Web Addresses
    readonly String HostAddress = "https://api.etilbudsavis.dk/v2/";
    readonly String Sessions = "sessions";
    readonly String Stores = "stores";
    readonly String Offers = "offers";
    readonly String Dealers = "dealers";

    //Keys
    readonly String ApiKey = "<Redacted>";
    readonly String ApiSecret = "<Redacted>";
    String XToken; //Same as a Session Token in documentation
    String XSignature; //Same as a Session Signature in documentation

    public eTilbudRetriever() {

        //Create a body consisting of the API key
        List<KeyValuePair<String, String>> body = new List<KeyValuePair<String, String>>();
        body.Add(new KeyValuePair<String, String>(ParamApiKey, ApiKey));

        //Send request to create a new session
        String response = SendWebRequest(Post, Sessions, body);

        //Get the Session Token from the response
        dynamic json = JObject.Parse(response);
        XToken = json.token;

        //Save the Session Signature as well (SHA256 version of API Secret combined with Session Token)
        XSignature = ConvertToSha256(ApiSecret + XToken);
    }

    public void GetDealersList() {
        GetList(Dealers);
    }

    public void GetStoresList() {
        GetList(Stores);
    }

    public void GetOffersList() {
        GetList(Offers);
    }

    private void GetList(string target) {

        List<String> resultSet = new List<String>();
        String result;
        int offset = 0;

        //Add desired parameters as headers for the eTilbudsavisen API
        List<KeyValuePair<String, String>> query = new List<KeyValuePair<String, String>>();
        query.Add(new KeyValuePair<String, String>(ParamLatitude, Latitude));
        query.Add(new KeyValuePair<String, String>(ParamLongitude, Longitude));
        query.Add(new KeyValuePair<String, String>(ParamRadius, Radius));
        query.Add(new KeyValuePair<String, String>(ParamLimit, Limit));
        query.Add(new KeyValuePair<String, String>(ParamOffset, offset.ToString()));

        //Retrieve a result through the request
        result = SendWebRequest(Get, target, query);

        /*
         * If result is valid, add it to the set of valid results.
         * Keep sending requests and increase the offset to avoid duplicated results
         * Stop when returned results are no longer valid
         */
        while (!String.IsNullOrEmpty(result)) {
            resultSet.Add(result);
            offset += Int32.Parse(Limit);
            query[query.Count-1] = new KeyValuePair<String, String>(ParamOffset, offset.ToString());
            result = SendWebRequest(Get, target, query);
        }
    }

    private String SendWebRequest(String method, String extension, List<KeyValuePair<String, String>> arguments) {

        try {
            String finalAddress = HostAddress + extension;

            //Add query to Address (if applicable)
            if (method.Equals(Get)) {
                finalAddress += '?';
                finalAddress += arguments[0].Key + '=' + arguments[0].Value;
                for (int i = 1; i < arguments.Count; i++) {
                    finalAddress += '&' + arguments[i].Key + '=' + arguments[i].Value;
                }
            }

            //Create request and set mandatory header properties
            var request = (HttpWebRequest)WebRequest.Create(finalAddress);
            request.Method = method;
            request.ContentType = ContentType;
            request.Accept = ContentType;

            //If a Session Token and Signature are available (= After session create), add as headers
            if (!String.IsNullOrEmpty(XToken)) {
                request.Headers.Add(HeaderXToken, XToken);
                request.Headers.Add(HeaderXSignature, XSignature);
            }

            //Create JSON string containing the desired body arguments (if applicable)
            if (method.Equals(Post)) {

                //Write body to API
                using (var writer = new StreamWriter(request.GetRequestStream())) {
                    writer.Write(MakeJsonBody(arguments));
                }
            }

            //get response as a JSON object in string format
            var response = (HttpWebResponse)request.GetResponse();
            return new StreamReader(response.GetResponseStream()).ReadToEnd();

        } catch (UriFormatException e) {
            Console.WriteLine(e.ToString());
            return null;
        } catch (WebException e) {
            Console.WriteLine(e.ToString());
            return null;
        }
    }

    private String ConvertToSha256(String text) {

        byte[] bytes = Encoding.UTF8.GetBytes(text);
        SHA256Managed hashstring = new SHA256Managed();
        byte[] hash = hashstring.ComputeHash(bytes);
        string hashString = string.Empty;

        foreach (byte x in hash) {
            hashString += String.Format("{0:x2}", x);
        }

        return hashString;
    }

    private String MakeJsonBody(List<KeyValuePair<String, String>> arguments) {

        String json = "{";

        foreach (KeyValuePair<String, String> kv in arguments) {
            json += "\"" + kv.Key + "\": \"" + kv.Value + "\"";

            if (arguments.IndexOf(kv) != arguments.Count() - 1) {
                json += ", ";
            }
        }

        json += "}";
        return json;
    }
}

}

Main ,这是相对于类执行的。从解决方案中删除这些行时,程序运行正常。

In Main, this is what is executed in relation to the class. The program runs fine when removing these lines from the solution.

eTilbudRetriever retriever = new eTilbudRetriever();
retriever.GetDealersList();


推荐答案


Windows 10,预览版内部版本10041

Windows 10, Preview Build 10041

这是程序崩溃的唯一提示。没有其他代码,您的代码也没有任何危险,Newtonsoft。Json已被数百万个程序以各种可能的方式猛烈抨击。您正在使用.NET Framework(v4.6)和操作系统的Beta版本。代表所有Microsoft客户感谢您帮助调试此新软件,您的问题并非我们要解决的问题。希望FEEE崩溃非常令人讨厌且难以调试。

That's the only cue to the possible reason why your program is crashing like this. There are no other ones, your code doesn't do anything dangerous and Newtonsoft.Json has been slammed every possible way by millions of programs. You are using beta versions of both the .NET Framework (v4.6) and the operating system. Thanks on behalf of all Microsoft customers to help debug this new software, your problem is not one that we'll have to troubleshoot. Hopefully, FEEE crashes are exceedingly nasty and hard to debug.

您要做的是向Microsoft提交崩溃过程的小型转储。因此他们可以修复潜在的错误。无论是什么,您的问题都没有任何提示。 也许这是x64抖动(项目代码名称RyuJit)的完整重写。它现在没有错误的可能性很小,并且这样的错误肯定会像这样使您的程序崩溃。

What you are supposed to do is submit a minidump of the crashed process to Microsoft so they can fix the underlying bug. Whatever it might be, there are no cues in your question. Maybe it is the complete rewrite of the x64 jitter (project code name RyuJit). The odds that it has no bugs right now are very slim and such a bug can certainly crash your program like this. That's just a wild guess though.

Microsoft免费提供了这些预览。他们的基本意图是在产品交付之前就将错误排除掉。应该在夏天左右发生。他们只有真正的办法才能确信他们的支持电话线在发货后不会过载。 Beta更新来得快而疯狂,.NET 4.6有6个CTP版本。非常空前的,通常不超过3个。至少其中一部分是VS2015的beta版本,该版本中有很多新内容。

Microsoft makes these previews available at no cost. Their underlying intention is to get the bugs out before the product ships. Should happen somewhere around the summer. Only real way they can have some confidence that their Support phone lines are not going to get overloaded once they ship the product. The beta updates come fast and furious, there have been 6 CTP versions of .NET 4.6. Quite unprecedented, there usually are no more than 3. At least part of it is the beta for VS2015, lots and lots of new stuff in that release. Which you are not using, that doesn't help either.

您在其中所扮演的角色是一名未付费的Beta测试人员。这往往与您的其他角色(一个靠编写和调试代码为生的程序员)不兼容。您的代码,不是别人的。如果您无法承受这种麻烦,那么唯一明智的选择就是退订该Beta计划。将计算机还原到框架和操作系统的已知良好版本。现在是.NET 4.5.2和Windows 8.1

Your role in this is one as an unpaid beta-tester. This tends to be rather incompatible with your other role, a programmer that makes a living writing and debugging code. Your code, not somebody else's. When you can't afford to be bogged-down like this then the only sensible thing to do is to unsubscribe from that beta program. Restore your machine to a known-good version of the framework and the operating system. Right now that's .NET 4.5.2 and Windows 8.1

这篇关于“ vshost32.exe已停止工作”;或“致命执行引擎错误”;在Visual Studio中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆