【发布时间】:2011-11-21 19:47:15
【问题描述】:
我正在使用 OPC 服务器编写 XML AJAX 服务。基于this 示例的 XML AJAX 服务。 我用单一属性完成了我的服务:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
下一步我将创建类析构函数:
~BoilerService()
{
try
{
ReadTimer.Dispose();
group.ReadCompleted -= new ReadCompleteEventHandler(group_ReadCompleted);
group.Remove(true);
server.Disconnect();
}
catch (Exception e)
{
System.IO.StreamWriter sw = new System.IO.StreamWriter("log.txt", true);
sw.WriteLine(DateTime.Now.ToString() +e.Message+ " "+ e.Source+" "+e.StackTrace + " destructor called.");
sw.Close();
sw.Dispose();
}
}
但是当我在 VS 中重建我的解决方案(在应用程序路径中替换文件)时,我得到 wp3.exe 未处理的异常错误窗口(Windows 7)。在 Windows 事件日志中,我看到以下文本:
Exception: System.Runtime.InteropServices.InvalidComObjectException
Message: COM object that has been separated from its underlying RCW cannot be used.
StackTrace: at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, Boolean& pfNeedsRelease)
at OPC.Data.Interface.IOPCServer.RemoveGroup(Int32 hServerGroup, Boolean bForce)
at OPC.Data.OpcGroup.Remove(Boolean bForce)
at OPC.Data.OpcGroup.Finalize()
我做错了什么?
VS 2010 给出警告: 1. 'System.Runtime.InteropServices.UCOMIEnumString' 已过时:'改用 System.Runtime.InteropServices.ComTypes.IEnumString。 http://go.microsoft.com/fwlink/?linkid=14202'。 2. 'System.Runtime.InteropServices.UCOMIConnectionPointContainer' 已过时:'使用 System.Runtime.InteropServices.ComTypes.IConnectionPointContainer 代替。 http://go.microsoft.com/fwlink/?linkid=14202'
可能是因为这个警告而出现这个错误吗?
【问题讨论】:
-
如果您想添加更多信息,请编辑您的问题,或使用您收到的答案下方的评论工具来讨论特定答案。答案字段仅用于此问题的答案,而不是讨论。
标签: c# ajax com service interop