How to implement this behavior in .NET 3.5, where there is no dynamic
keyword.
Guid CLSID_ShellApplication = new Guid("13709620-C279-11CE-A49E-444553540000");
Type shellApplicationType = Type.GetTypeFromCLSID(CLSID_ShellApplication, true);
dynamic shellApplication = Activator.CreateInstance(shellApplicationType);
dynamic windows = shellApplication.Windows();
for (int i = 0; i < windows.Count; i++)
windows.Item(i).Refresh();
I tried using
MethodInfo windowsMethod = shellApplicationType.GetMethod("Windows");
but GetMethod
returns null
.
If what you want is dynamic behaviour in .NET < 4.0, you can go DLR straight Check this site http://dlr.codeplex.com/ And also you can take a look at this video. The guy behind IronPython shows how to implement a DLR binder for office (which uses COM) http://channel9.msdn.com/blogs/pdc2008/tl10
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.