Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net CreateObject导致应用程序池挂起_Vb.net_Iis - Fatal编程技术网

Vb.net CreateObject导致应用程序池挂起

Vb.net CreateObject导致应用程序池挂起,vb.net,iis,Vb.net,Iis,我正在运行这个VB.NET代码来将WAV文件转换为MP3。它通常每小时运行20次。大约每天一次,应用程序池会随机挂起objMP3=CreateObject(“AudioConverter.AudioConverterx”)。重新启动应用程序池将修复此问题 'convert the file objMP3 = CreateObject("AudioConverter.AudioConverterx") objMP3.Logfile = myLogFileName objMP3.Convert(my

我正在运行这个VB.NET代码来将WAV文件转换为MP3。它通常每小时运行20次。大约每天一次,应用程序池会随机挂起
objMP3=CreateObject(“AudioConverter.AudioConverterx”)
。重新启动应用程序池将修复此问题

'convert the file
objMP3 = CreateObject("AudioConverter.AudioConverterx")
objMP3.Logfile = myLogFileName
objMP3.Convert(myWAVfile, myMP3file, "-cMP3")
objMP3 = Nothing
每次发生这种情况时,事件日志都会出现以下错误:

故障应用程序w3wp.exe,版本6.0.3790.3959,戳记45d6968e, 故障模块audioconverter.dll,版本0.0.0.0,印章2a425e19, 调试?0,故障地址0x0000402e

系统日志包含以下内容:

为应用程序池“tts.servername.com”提供服务的进程已超过时间 关闭期间的限制。进程id为“1340”

我能想到的唯一一件事是应用程序没有正确关闭。我已经读到,
objMP3=Nothing
实际上并没有关闭它(或者它的工作原理与经典vb中的不同)

我还在服务器上设置了调试诊断。当挂起发生时,每秒仅使用此行多次创建一个大文件(>8GB)

[11/8/2011 9:28:36 PM]第一次机会异常-0xc0000005由以下原因引起 系统ID为2548的线程


有什么想法吗?

为了正确地从.NET释放COM对象,并确保它的终结器运行,您应该调用

这是我使用的代码:

    'convert the file
    objMP3 = CreateObject("AudioConverter.AudioConverterx")
    ' Do stuff
    ReleaseComObject(objMP3)

    private void ReleaseComObject(object o)
    {
        try
        {
            if (o != null)
            {
                // As per the documentation, call ReleaseComObject in a loop
                // until all references are released.
                while (System.Runtime.InteropServices.Marshal.ReleaseComObject(o) > 0)
                {
                }
            }

            o = null;
        }
        catch (System.Runtime.InteropServices.COMException)
        {
            // Do nothing. We don't want exceptions to leak out of this method.
        }
    }

该COM服务器只是因为访问冲突而崩溃。本机代码的标准故障模式。您需要调试它或将其丢弃。