CreateObject 导致应用程序池挂起

发布于 2024-12-18 17:33:36 字数 921 浏览 0 评论 0原文

我正在运行此 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 的线程

有什么想法吗?

I am running this VB.NET code to convert WAV files to mp3s. It typically runs about 20 times an hour. Randomly, about once a day, the app pool hangs on objMP3 = CreateObject("AudioConverter.AudioConverterx"). Restarting the app pool fixes it.

'convert the file
objMP3 = CreateObject("AudioConverter.AudioConverterx")
objMP3.Logfile = myLogFileName
objMP3.Convert(myWAVfile, myMP3file, "-cMP3")
objMP3 = Nothing

Every time this happens, the Event Log has this error:

Faulting application w3wp.exe, version 6.0.3790.3959, stamp 45d6968e,
faulting module audioconverter.dll, version 0.0.0.0, stamp 2a425e19,
debug? 0, fault address 0x0000402e.

And the system log has this:

A process serving application pool 'tts.servername.com' exceeded time
limits during shut down. The process id was '1340'.

The only thing that I can think of is that the application isn't being closed properly. I've read that objMP3 = Nothing doesn't actually close it (or it doesn't work the same as in classic vb).

I have also set up Debug Diagnostics on the server. When the hang occurs, a large file (> 8GB) is created with only this line multiple times a second.

[11/8/2011 9:28:36 PM] First chance exception - 0xc0000005 caused by
thread with System ID: 2548

Any Ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

£烟消云散 2024-12-25 17:33:36

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

这是我使用的代码:

    '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.
        }
    }

In order to correctly release a COM object from .NET, and ensure it's finalizers are run, you should call Marshall.ReleaseComObject.

This is the code I use:

    '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.
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文