I want to test the behavior of a certain piece of .NET code in partial trust environments. What's the fastest way to set this up? Feel free to assume that I (and other readers) are total CAS noobs.
@Nick: Thanks for the reply. Alas, the tool in question is explicitly for unmanaged code. I didn't say "managed" in my question, and should not have assumed that people would infer it from the ".NET" tag.
This is an excellent question, especially from a TDD point of view and validating code under different trust scenarios.
I think the way I'd approach this would be something along the lines of -
Create an AppDomain in my TDD code using the AppDomain.CreateDomain() overload that allows you to pass in a PermissionSet. The PermissionSet would be constructed to match the different trust scenarios you'd want to test against.
Load the assembly containing logic under test into the app domain
Create instances of types/call methods etc in app domain, trap security exceptions
Something kinda like that. I've not had time to knock up a proof of concept yet.
The functionality you're looking for is built-in into visual studio :
On the security tab of your project, there's an "Advanced ..." button which let you configure whether you want to debug in full trust, or on a specified trust level.
Use the Microsoft Application Verifier.
AppVerifier helps to determine:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With