C# Dynamic and Error : Dynamic Operations Can Only Be Performed In Homogenous AppDomain.

I have been using dynamic since its introduction in .net framwork 4.0. I do something like using a c# sortedlist with id and object, or other usages as assigning a complete object to a dynamic variable.

In ASP.Net MVC I never had problems assigning dynamic variables, instead of var’s but when I use it with SharePoint, it causes me this specific problem : Dynamic Operations Can Only Be Performed In Homogenous AppDomain 

Let me give you an elementary background to what I would like to achieve :

Using SharePoint lists with ~30 columns each having different datatypes, its only convenient to use SortedLists where its additionally sophisticated to Search specific item/ iterate it multiple times.

Its worth pointing out, according to this blog http://cc.davelozinski.com/c-sharp/fastest-collection-for-string-lookups its charmingly clear that SortedLists on single threaded search performs well for string lengths between 12-128 chars, especially using it with SharePoint 2013 its probably very much essential.

datatypelistspeed

And the developer usage was implemented as below :

sortedlist

In the complex world of SharePoint the OwsTimer service especially when your writing SPTimerJob based applications on SP2013, using dynamic are avoided due to LegacySecurityPolicy on runtime. C# Dynamic datatypes withdraws type checking at compilation time; instead, it resolves its type during run time.

This behaviour directly conflicts SharePoint OwsTimer jobs config file.

owstimerconfig

Workaround to this is to enable the LegacySecurityPolicy to true and using the Management Shell run the IIS reset function call.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Create a website or blog at WordPress.com

Up ↑