简体   繁体   English

ASP,Server.CreateObject,MTS和C#对象池-重用问题?

[英]ASP, Server.CreateObject, MTS and C# object pooling — a reuse problem?

I'm trying to debug an "occasional" problem. 我正在尝试调试“偶然的”问题。 We've got a classic ASP application that needs to send email. 我们有一个经典的ASP应用程序,需要发送电子邮件。 For whatever reasons it's using a C# object exposed via COM to do this send; 无论出于何种原因,它都使用通过COM公开的C#对象来执行此发送; the c# object is a simple wrapper around MailMessage and SMTPClient, using SendAsync to do the send. c#对象是围绕MailMessage和SMTPClient的简单包装,使用SendAsync进行发送。 On the ASP side the object is Server.CreateObject()'d before each mail is sent, but mail messages are sent in a tight loop. 在ASP方面,在发送每封邮件之前,对象都是Server.CreateObject(),但是邮件消息却是紧密循环发送的。 This should result in a new COM object (and therefore a new c# object) for each message. 导致对每个消息中的新的COM对象(因此一个新的C#对象)。 However, we're seeing messages dropped and messages sent to multiple recipients as if the object is being reused. 但是,我们看到消息已丢弃,消息已发送给多个收件人,就像对象被重用一样。

After some research into MTS (never thought I'd go there again!) I've remembered/discovered that Server.CreateObject goes through MTS and MTS will pool COM objects in order to "help" me. 在对MTS进行了一些研究之后(再也没有想到我会再去那里!),我记得/发现Server.CreateObject通过MTS,MTS会汇集COM对象以“帮助”我。 We've changed the ASP code to do a new ActiveXObject instead, which I thought didn't go through MTS, but we have the same problem. 我们已经更改了ASP代码以改为执行新的ActiveXObject,我认为这没有通过MTS,但是我们有同样的问题。

Am I correct in assuming that the ServicedComponent interface in .net is the .net/com+ version of ObjectControl interface? 我是否假设.net中的ServicedComponent接口是ObjectControl接口的.net / com +版本是否正确? If I inherit from ServicedComponent will the object then be set to allow pooling = false? 如果我从ServicedComponent继承,则将对象设置为允许pooling = false? I'd rather make the change in the ASP, but if that's not possible, then I can make the c# change too. 我宁愿在ASP中进行更改,但是如果这不可能,那么我也可以进行c#更改。

Thoughts? 思考?

Edit: The page language is JScript too, not the "normal" VBScript. 编辑:页面语言也是JScript,而不是“普通” VBScript。

Server.CreateObject and new ActiveXObject will all to the same thing in this case. 在这种情况下,Server.CreateObject和新的ActiveXObject都将处于同一状态。

COM+ won't pool an object that doesn't explictly indicate that it can be pooled. COM +不会合并未明确指示可以合并的对象。

What I'd be inclined to do is to investigate what the reasons are for using a .NET component here, why is CDO.Message not being used? 我倾向于做的是调查这里使用.NET组件的原因,为什么不使用CDO.Message? Use of SendAsync is especially confusing. 使用SendAsync尤其令人困惑。 If you have a tight loop just sending emails then SendAsync does very little for you. 如果您有一个狭窄的循环,只是发送电子邮件,那么SendAsync对您几乎没有帮助。

I can't think a good reason to avoid using CDO.Message in this case but of course that could be because we're missing other factors. 我不能认为在这种情况下避免使用CDO.Message的充分理由,但是当然这可能是因为我们缺少其他因素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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