This message was discovered on microsoft.public.dotnet.framework.interop.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
| Invalidlastname |
Hi, We used .NET EnterpriseServices Queued components in our application to for certain asynchronous processes (code fragments was attached) However, we found out that the "Objects", "Activated" counts in the Component Services MMC are growing constantly. The application is running on Windows Server 2003 with .NET 1.1 framework. I found some discussion threads from google search
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=b6cc0fd6.0401080752.718eb13%40posting.google.com&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26selm%3Db6cc0fd6.0401080752.718eb13%2540posting..google.com
From this discussion, it looks like a known bug in the .NET while using queued components. (another discussion is sort of related http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=1ee11286.0303130854.34c4293b%40posting.google.com&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26selm%3D1ee11286.0303130854.34c4293b%2540posting.google.com )
I also found a KB Q article http://support.microsoft.com/?kbid=826915 which may be related. (because the article does mention that it applies to .NET 1.0 and does not say anything about .NET 1.1 running on Windows 2k3 server) I am very interested to know has anyone applied the patch mentioned in the Q article and resolved the issue?
I really appreciate that if anyone can give me some suggestions, or point me what I did wrong using the queued components.
If this is a bug, is there any patch available and where I can download the catch?
Thanks
ILN
sample code of using queued components
///////////////////////////////////////////////////////////
IAsyncAgent agent = null;
try
{
string sClsPath = "queue:/new:XXX" ;
agent = (Agents.IAsyncAgent) Marshal.BindToMoniker(sClsPath);
agent.xxx();
}
catch(Exception ex)
{
...
}
finally
{
while(agent!=null && Marshal.ReleaseComObject(agent) > 0) {}
agent = null;
}
///////////////////////////////////////////////////////////
|
|
| |
| |
| Peter Huang (VIP) |
Hi,
Based on my knowledge, the KB article is just applied to .net framework 1.0, and will not applied to 1.1. For your problem, is it specifed to the queued components, if you did not enable the queued component feature, did the problem persists? Also what did you do you in agent.xxx(), you may try to simplify it, e.g. just call debug.writeline. Is there any other application is using the queued component? You may try to test with one application to call the queued component, also you may try to call code below after set the agent to null in the finalize block.
GC.Collect() GC.WaitForPendingFinalizers() GC.Collect() GC.WaitForPendingFinalizers()
you may have a try and let me know the result.
Best regards,
Peter Huang Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
| |
| |
| Invalidlastname |
Peter, Thanks for the quick response. I have tried all your suggestions and none of them worked in my case.
In your best knowledge, is this is an issue of using queued component in ..NET? If this is an issue, is there any fix or workaround available?
""Peter Huang"" <Click here to reveal e-mail address> wrote in message news:aKB#Click here to reveal e-mail address... [Original message clipped]
Just try to clarify it. Are you saying that such issue has been fixed in the ..NET 1.1 ?
[Original message clipped]
If I used Marshal.BindToMoniker("new:XXX") to create the object, then I got the same issue as I used it as queued component. However, if I used "new" to create object then call Dispose when the process finished, the "Objects" and "Activated" will remain 0 (The COM+ application will be activated, but all counts in MMC remain 0)
[Original message clipped]
behavior
> Is there any other application is using the queued component? The answer is no.
[Original message clipped]
tried it, surprisingly, it DID NOT work either
[Original message clipped]
|
|
| |
| |
| Peter Huang (VIP) |
Hi,
I will keep researching the issue and update you with new information ASAP.
Best regards,
Peter Huang Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
| |
| |
| Peter Huang (VIP) |
Hi,
I have comfirm with our senior engineer that KB's bug will not apply here. About the QC issue, you are probably not overriding Dispose in that IAsyncAgent i/f (I assume that is your interface?). e.g.
[Server] using System.Reflection; using System.EnterpriseServices; using System; [assembly: ApplicationName("QCDemoSvr")] [assembly: ApplicationActivation(ActivationOption.Server)] [assembly: ApplicationQueuing(Enabled=true, QueueListenerEnabled=true)]
namespace QCDemo { public interface IQComponent { void DisplayMessage(string msg); void Dispose(); }
[InterfaceQueuing(Interface = "IQComponent"),EventTrackingEnabled(true)] public class QComponent : ServicedComponent, IQComponent { public void DisplayMessage(string msg) { System.Diagnostics.Debug.WriteLine(msg+ "Processing message"); } } }
[client] private void button1_Click(object sender, System.EventArgs e) { IQComponent iQc = null; try { iQc = (IQComponent)Marshal.BindToMoniker("queue:/new:QCDemo.QComponent"); } catch { MessageBox.Show("Cannot create Queued Component"); } Debug.WriteLine("Send Message"); iQc.DisplayMessage (this.textBox1.Text); iQc.Dispose(); //Call Dispose here Marshal.ReleaseComObject(iQc); }
Best regards,
Peter Huang Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
| |
| |
| Invalidlastname |
Peter, Thanks for helps and you have resolved my issue =) Now the "Objects" and "Activated" counts go back to 0 when the calls completed.
I think the trick part is to know the correct order of methods, which release the references of the objects, should be called. Originally I have my interface inherit the IDisposable and I got "QueryInterface for interface System.IDisposable failed." and I didn't come up the ideal to explicitly define the Dispose() method in the interface, so the client program can call the dispose method before the Marshal.ReleaseComObject()
Anyway, I cannot thank you more for the helps you provided. It would be very helpful to see MSDN documents cover such valuable information, such as < call Dispose() here =)
Rgds,
ILN
""Peter Huang"" <Click here to reveal e-mail address> wrote in message news:Click here to reveal e-mail address... [Original message clipped]
|
|
| |
| |
| Peter Huang (VIP) |
Hi,
I am glad that the problem has been resolved.
Cheers!
Best regards,
Peter Huang Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
| |
| |
| Invalidlastname |
Peter, one last question. I am just curious why I got the following exception if I make the interface inherit the IDisposable instead of having Dispose() explicitly defined in the interface ? System.InvalidCastException: QueryInterface for interface System.IDisposable failed.
at System.IDisposable.Dispose()
// Code Snippets =========================== // Interface
public interface IAsyncAgent : IDisposable
{
....
//void Dispose(); // remove this line since the interface itself inherits the IDisposable
}
//client Agents.IAsyncAgent agent = null;
agent.Dispose(); //<<<error occurred. System.InvalidCastException: QueryInterface for interface System.IDisposable failed.
while(Marshal.ReleaseComObject(agent) > 0) {}
agent = null;
""Peter Huang"" <Click here to reveal e-mail address> wrote in message news:Click here to reveal e-mail address... [Original message clipped]
|
|
| |
| |
| Peter Huang (VIP) |
Hi,
From the TLB file generated by the QC, IAsyncAgent is derived from IDispatch not from IDispose, the QI will failed.
Best regards,
Peter Huang Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|