取消牵引注记时,引发nullReferenceException

IAnnotationFeature pAnn = pFeature as IAnnotationFeature;
ISymbolCollectionElement pCollecionElement = pAnn
.Annotation as ISymbolCollectionElement;
ITextBackground pGround = pCollecionElement.Background as ITextBackground;

//pGround 不为null,代表这个注记使用了牵引线样式
//我猜想取消牵引注记就是 将 pCollencionElement.Background 赋值为null
//但是一直失败。
if (pGround != null)
{
//方法一:直接赋值为null,在这里会出现nullReferenceException 的错误,而pCollectionElement,和background 并不为null
pCollecionElement.Background = null;
//方法二:直接释放background也不行。

//ILineCallout plc = pGround as ILineCallout;
//Marshal.ReleaseComObject(plc);我尝试释放对象,来取消牵引注记样式,但是不成功
pAnn.Annotation = pCollecionElement as IElement;
}
已邀请:

要回复问题请先登录注册