1

我有一段代码可以创建一个新的 SQL-Server Express 数据库,然后运行一个预定义的表生成/填充脚本。这是一项非常直接和简单的任务,并且代码在正常操作下运行良好。在我们的一台测试机器上,这个创建功能在创建数据库之后但在填充它之前停止。它只是挂起,没有错误消息,没有死锁(ui 仍然响应),也没有 CPU 使用率。

进一步调查和调试确定执行 LoadDatabaseTables() 函数调用之前的行,但从未到达 LoadDatabaseTables() 中的第一行。如何准确地调用一个函数,但程序甚至无法执行该函数的第一行?

有问题的代码是用 C# 编写的:

    ...snip...
    bool success=false;
    try
    {
        //...code that creates db, working as intended...
    }
    catch(Exception e)
    {
        //...error handling...
    }
    finally
    {
        //Params is a locally defined struct, containing int, bool, and string members
        if(CreateScript(Params))  //generates appropriate script successfully, returns true
        {
            System.Windows.MessageBox.Show("About to enter load script");
            if(LoadDatabaseTables(Params))
            {
               success=true;
            }
        }
    }
    return success;
}

private bool LoadDatabaseTables(DatabaseParams Params)
{
    System.Windows.MessageBox.Show("Entered the load script");
    bool success = false;
    Server server = null;
    try
    {
        //...sql calls...
        success = true;
    }
    catch (Exception ex)
    {
        //...exception handling...
    }
    return success;
}
...snip...

The first message "About to enter load script" is reached but the "Entered the load script" is not displayed, and the rest of the function does not execute, no exceptions are raised, nothing is returned.

Unfortunately, this machine does not have the necessary tools/licenses to run full debugging, and the problem only occurs on this one machine. The message boxes obviously are not included in the regular version of the code, and a just being used to attempt to diagnose the problem. The code executes normally on other systems with and without these message boxes.

Has anyone come across this kind of error before? Any help would be most appreciated!

4

0 回答 0