开发者

Do I need to use Marshal.ReleasComObject on 4.0 'dynamic' variables?

I have the following C# code:

int CallFooMethod()
{
   Type type = TypeDelegator.GetTypeFromProgID("SomeCOMDll.SomeCOMClass");

   dynamic foo = Activator.CreateInstance(type);

   return (int)foo.Foo();
}

My question is, do I need to use Marshal.ReleaseComObject on the variable named foo?

I would normally do this if I was using the reflection in the usual way for invoking a method on a COM object, but since dynamic is all about late binding and magic, I wonder if variables of type dyn开发者_StackOverflowamic will take care of this for me...

Thanks


You shouldn't call it at all in most situtations, unless you really know what you're doing.

dynamic won't make a difference. dynamic is just a different way to call methods on an object; it doesn't affect the object at all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜