I\'m working on a C# application that allows users to basically import tables of data, and then enter their own formulas in a mini-language to compute new columns from the under
I think this has something to do with CAS (Code access security).
CAS is assembly based. When you code calls a protected method, the .NET framework runtimes checks your assembly to see if it has been granted on or more permissions necessary for the method. The .NET Framework rutime then walks the stack to check every assembly in the stack for these ermissions. If one assembly does not have all of the required permissions, a securityexception is raised and the code is run.
The below is what I think is happening to your code.
... a stack walk occurs and policy check is preformed every time that the method is called. This is a particular problem for components in a class library, which may be called many times. In this situation, you can use link demand to indicate that the permission set check is performed on at link time as part of the JIT compliction process. To do this, you decorate the method by using a permission attribute that has a parameter of the value
SecurityAction.LinkDemand
.
I hope this helps, it looks like all you need to do is set the SecurityAction.LinkDemand
attribute. The quoted text comes from Advanced foundations of Microsoft .NET 2.0 Development.
Regards