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.
精彩评论