简体   繁体   中英

Visual Studio ASP.NET MVC debugger keeps quitting when I instantiate a new object

I being for the last 12 hours trying to understand why this is happening.

I am working in a ASP.NET MVC (C#) application where I created an abstract class that has base information for all the future models class.

Follow it's an example of code that I have done:

namespace TestingModelBind.Models.Home
{
    public abstract class Person 
    {
        public int PersonId {get; set;}
        public string Name { get; set; }
        public string LastName { get; set; }

        private string _personValueHash;
        public string PersonValueHash
        {
            get { return //call function that get the Hash for the Person}
            set { _personValueHash= value; }
        }

        public abstract void GetPerson();

        internal abstract void SavePersonInformation();

        public void SetPerson()
        {
           if (_personValueHash!=PersonValueHash){SavePersonInformation();}
        }
    }

So I have a created an Abstract Class since the Implementation for GetPerson and SavePersonInformation depends on the Kind of individual. Here is the the code where I use the Abstract Class Person in a Worker Class

namespace TestingModelBind.Models.Home
{
    public class Worker: Person
    {
        public bool Consultant { get; set; }
        public string City { get; set; }
        public override void GetPerson()
        {
            // Code to retrieve the Worker Information Based on the PersonId
        }
        internal override void SavePersonInformation()
        {
            // Code to Persist the Worker Information
        }
    }
}

And here is the Controller where I use the Final Worker Class

public ActionResult Index(int? id)
{
    Worker dataModel = new Worker(); // This is the line where the Debugger Crash
    if (id!=null)
    {
        dataModel.PersonId = (int) id;
        dataModel.GetPerson();
    }
    return View(dataModel);
}

Now the issue is that all the time that I try to instantiate the Worker Class the Debugger in Visual Studio crash giving me as an error this message:

"The debugger cannot continue running the process. Process was terminated."

I did keep a file from the IntelliTrace and when it gets to the moment of the crash I am getting this

"No Source Available. No symbols are loaded for any call stack frame. The source code cannot be displayed. Itellitrace time context: : Function Entry:[Unknown Method]"

.

I am going crazy on this, and is holding me back since in the real project.

Any Ideas? Thank You so much.

When the Visual Studio debugger exits suddenly and the process in question terminates the problem is typically one of the following

  • Memory corruption deep within the CLR
  • Stack overflow

For your scenario I would say the Stack Overflow case is much more likely. I would set a breakpoints in the methods you omitted and re-run the scenario. If it is a stack overflow your should see your methods getting hit repeatedly and unendingly.

The Code that calculate the Hash for the Object. I am taking all the Properties values, creating a string and then Hashing the string (I am doing this to know if I really need to save the information or the user just browsed). The issue is that I was using Reflection for the looping on all the properties, and this will cause a problem when you do this piece of code and you are using some inheritance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM