标签: visual-studio-debugging

调试期间鼠标悬停(DataTip)后自动实例化的属性

大家晚上好。我发生了一些非常奇怪的事情。经过多次测试,我发现,在调试模式(Visual Studio 2017)下,通过鼠标悬停在属性上出现DataTip后,它被独立实例化并设置为空。它是 Visual Studio 中的错误还是发生这种情况的原因?

    private List<int> myVar;
    public List<int> MyProperty
    {
        get
        {
            if (myVar == null)
            {
                myVar = new List<int>();
                return myVar;
            }
            else
                return myVar;
        }
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        List<int> list = MyProperty;
    }
Run Code Online (Sandbox Code Playgroud)

鼠标悬停在 myVar 上

如您所见,如果您将鼠标放在 myVar 上,您将正确获得 null,但是如果您将其放在 MyProperty 上,它会自动实例化,并且 myVar 也会立即实例化。

鼠标悬停在 MyProperty 上这种行为在调试过程中给我带来了很多问题,我花了很长时间才弄清楚发生了什么。这是正常行为还是错误?请注意,我没有提供 set 访问器。

c# visual-studio-debugging

1
推荐指数
1
解决办法
46
查看次数

如何在 Visual Studio 中使用注册调试窗口

我目前正在学习汇编,并且正在使用 Visual Studio 来完成此任务。然而,当我去评估寄存器时,调试下拉列表中没有选项。我需要安装它或激活设置吗?抱歉,没有足够的声誉来嵌入图片。

debugging assembly cpu-registers visual-studio visual-studio-debugging

1
推荐指数
1
解决办法
4053
查看次数

当鼠标悬停时,Visual Studio 调试器将日期时间显示为刻度,而不是可理解的日期字符串格式

在 Visual Studio 中(我使用的是 2019),在调试过程中,当我将鼠标悬停在DateTime对象上时,它会显示 Ticks 中的日期,而不是可读的日期字符串(例如 YYYY-MM-dd HH:mm:ss 等) 。

下图显示了这种恼人的行为。

文本

我记得在我的旧 Visual Studio 2017 中,它以“YYYY-MM-DD HH:mm:ss.ttt”格式显示日期时间对象。我该如何改变这个?

c# debugging debuggervisualizer visual-studio visual-studio-debugging

1
推荐指数
1
解决办法
756
查看次数

VS 分析器,源信息不可用

我第一次尝试使用 Visual Studio 性能分析器,我对分析器成功检测到的我的特定功能感兴趣。但是,当我单击它时,我收到“源信息不可用”。

我该如何解决?

在此输入图像描述

库中的所有外部函数都是可见的。“lab.cpp”中的任何函数都不会显示。我的意思是,甚至“main”都不可用。这是我编辑的唯一文件,我在其中编写了所有代码:

在此输入图像描述

c++ performance profiler visual-studio visual-studio-debugging

1
推荐指数
1
解决办法
3879
查看次数

c ++存储数组范围内的值

char *asd = new char[5];
asd[10] = 'f';
Run Code Online (Sandbox Code Playgroud)

为什么这个代码在运行whit debug时没有给我一个错误?它会在发布版本中导致崩溃.

c++ arrays visual-studio-debugging

0
推荐指数
1
解决办法
107
查看次数

Visual C++:无效的分配大小.为什么会这样?

我是学习C++的过程.我无法在VC++上调试我的一些代码,但有以下错误 -

Debug Error
*path to filename.exe*
Invalid allocation size:429496723 bytes.
Run Code Online (Sandbox Code Playgroud)

当调试器到达以下块时,精确地发生错误:编辑:我添加了整个main函数以帮助检查maxlen是否正在接受任何意外值(尽管我没有注意到)

int main(){

    vector <Student_info> students;

    Student_info record;

    string::size_type maxlen=0;// length of the longest name

    //read and store all the students data.

    //maxlen contains the length of the name of the longest student.

    while (read(cin,record)){
    // find the length of the longest name
        max(maxlen,record.name.size());
        //add the student record to the vector.

        students.push_back(record);
    }
    //arrange the records alphabetically.
    sort(students.begin(),students.end(),compare);// this may look weird but the fact …
Run Code Online (Sandbox Code Playgroud)

c++ debugging visual-studio-2008 visual-studio-debugging

0
推荐指数
1
解决办法
3444
查看次数

如何调试我自己的DLL文件作为插件导入到其他应用程序?

我们在Visual Studio中创建了一个C#项目,结果是一个DLL文件.如果我们将该DLL文件导入第三方应用程序,它将充当插件.一切都好.但我的DLL文件中有一个错误,我可以通过放置一个调试点找到它.但我不知道如何为导入第三方应用程序的DLL执行此操作.

c# debugging dll visual-studio-2010 visual-studio-debugging

0
推荐指数
1
解决办法
166
查看次数

如何调试异常

将异常记录到数据库或评估事件查看器非常有帮助.很多时候我们常常想知道如何重现错误,以便我们可以调试它.您可以应用一些良好实践来序列化调用,然后稍后通过一些工作重现错误并最终调试和修复.我想知道有哪些工具和/或最佳实践可以有效地调试错误,以便根据收集的异常信息快速修复.换句话说,收集有关任何给定异常的信息,并通过代码快速加载到调试会话\步骤,并更有效地解决错误.

这是我认为是梦想的东西,但如果存在则会非常有用.

try
{
    //Do something that breaks
}
catch (Exception Ex)
{
    LogExceptionExecution();
}
Run Code Online (Sandbox Code Playgroud)

序列化从LogExceptionExecution()收集的信息; 现在将信息序列化完整地获取信息并直接加载到visual studio中.然后,Visual Studio将在方法开始时创建断点并开始调试会话.调试会话将加载所有内容以重新创建导致异常的原因.这将允许您调试和修复错误,而无需花费宝贵的时间来重新创建环境并加载错误期间使用的代码以调试和修复代码.

c# debugging exception visual-studio-debugging

0
推荐指数
1
解决办法
205
查看次数

即使使用delete [],也会调试断言失败

我是编程的初学者,最近编写了这段代码

#include<iostream>
using namespace std;


void removeAllCharacters(char * , char * );
void printArray(char*);

void deleteArrays(char*,char*);

int main()
{
            char * source,*remove;
            source=new char[18];
            remove=new char[10];

            source="Hello how are you";
            remove="Hi Its me";

            removeAllCharacters(source,remove);
            printArray(source);

            deleteArrays(source,remove);
            system("pause");
            return 0;
}

void removeAllCharacters(char * source, char * remove)
{
            int N1=strlen(source)+1;
            int N2=strlen(remove)+1;

            bool arr[128] = {false};

            for(int i=0;i<N2-1;i++)
            {
                arr[remove[i]]=1;
            }

            char *newSource=new char[N1];

            for(int i=0,j=0;i<N1-1;i++)
            {
                if(arr[source[i]]==0)
                {
                    newSource[j++]=source[i];
                }
            }

            delete  [] source;
            source=newSource;
            newSource=0;
}

void printArray(char* …
Run Code Online (Sandbox Code Playgroud)

c++ visual-studio-debugging

0
推荐指数
1
解决办法
841
查看次数

调试不返回的异步任务

我正在使用小型WPF桌面实用程序,并且正在使用async / await方法来允许事物并行处理。

但是,我一直遇到一个问题,一个等待已久的异步任务根本就不会返回。没有异常抛出,如果我在调试器中暂停该应用程序,则调用堆栈会说它正在运行“外部代码”,该行由调用异步任务的行调用。(具体来说,它挂在:WindowsBase.dll!System.Windows.Threading.DispatcherSynchronizationContext.Wait(System.IntPtr [] waitHandles,bool waitAll,int millisecondsTimeout)。)可以解决此问题,但是每次必须添加调试代码来确定停止执行的行。(相同的代码可能多次执行都可以正常执行,然后挂起)在等待我自己的异步方法和等待框架异步方法(例如,EG Stream.CopyToAsync和Stream.ReadAsync)上都发生了相同的问题)

有没有办法研究在Visual Studio 2017中执行任务?我尝试打开“任务”窗口,但是除了“没有要显示的任务”之外,我什么都没得到-可能是我没有正确使用该窗口?

FWIW,我正在做很多(数百)并发后台操作,但是没有一个重叠。通常是Web服务调用,文件系统读取和MD5校验和计算。异步/等待是否可以在不冻结的情况下同时执行限制?还是最大的等待嵌套?

c# visual-studio-debugging async-await visual-studio-2017

0
推荐指数
1
解决办法
1778
查看次数