Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

Method caching of dynamic objects

$
0
0

I instantiate a dynamic object by using the Activator.CreateInstance() method, e.g:
dynamic dynObject = Activator.CreateInstance(Type.GetTypeFromProgID("SomeProgID"));

The object created is a COM object with lots of methods (hundreds) defined and it takes quite some time to run a method the first time due to the runtime going through the objects capabilities (methods etc.) and caching them, in this case approx. 1500ms.

Say I need less than 10% of the objects offered interface, is it possible to restrict the runtime to cache only a specified set of methods, e.g. by a method pattern or similar ? (possibly increase the cache later if needed).

I have tried using reflection instead and it is initially faster, later slower and of course much more complex and error prone.


Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>