110,536
社区成员
发帖
与我相关
我的任务
分享
object missing = System.Reflection.Missing.Value;
object oFalse = (object)false;
//释放document对象
if (document != null)
{
document.Close(ref oFalse, ref missing, ref missing);
System.Runtime.InteropServices.Marshal.ReleaseComObject(document);
}
//释放Word.Application
if (WinWordControl.wd != null)
{
WinWordControl.wd.Quit(ref oFalse, ref missing, ref missing);
System.Runtime.InteropServices.Marshal.ReleaseComObject(WinWordControl.wd);
}
document = null;
WinWordControl.wd = null;
//垃圾回收,如果不使用这句会,再次加载控件时,会出现异常
GC.Collect();
window.attachEvent('onbeforeunload',hostRelease);
function hostRelease()
{
//调用ActiveX释放方法
IActiveXContract.UnloadControl();
}
[
Guid("24FBC1BC-198A-4b21-BFF4-40C86FAF58F8"),
ProgId("UPM.WordActiveX.WordCtl"),
ClassInterface(ClassInterfaceType.None),
ComDefaultInterface(typeof(IWordCtlComInf)),
ComVisible(true)
]
public partial class WordCtl : UserControl,IWordCtlComInf, IObjectSafety, IWordActiveX
{}