> Thanks Nicole
>
> When the control is working, we'd like to distribute it to our clients
> over the internet. Ideally, they would just configure the website as a
> 'Trusted site' in IE, and then confirm they'd like to run an ActiveX
> control when it starts to run.
You really need to give up on the trusted site approach. This will not work
without modifying the CAS policy on the client and, as long as you're going
to do that, you might as well make a safer, more constrained modification.
> But I can't get it working even on my development PC, which I guess
> would be a local policy problem.
Have you made any CAS policy modifications at all yet? If so, what are
they?
> The user control works correctly in IE
> until it requests a privileged operation e.g. file access. From what
[quoted text clipped - 5 lines]
> around with this, but I'm not really sure what settings to use, and the
> certificate is still untrusted.
The ClickOnce settings are irrelevant to an IE-hosted control. You should
basically just ignore the ClickOnce tab of this project's properties window.
> 2. In VS project properties: Security: I've tried various options, but
> assume "Enable ClickOnce Security Settings" with "This is a full trust
> application" is correct
Nope. An IE-hosted control has no access to this ClickOnce functionality.
> 3. Using Caspol or similar to trust the assembly. I've expriemtented
> with this without success. However, it's not really the angle I'd
> prefer to take, as we wouldn't want our clients to manually configure
> their computers in this way just to run our program.
Unfortunately, their CAS policy will need to be modified if your control
requires permissions not granted by their existing policy. You can given
them a script that would help automate this policy modification, but it will
likely need to be manually executed under an administrator account if you're
distributing to an internet audience. If this isn't acceptable, you have
two main alternatives:
1. Modify your control so that it doesn't require elevated CAS permissions.
Depending on what the control is meant to do, this may or may not be
possible. If you could provide a bit more detail about what your code is
doing (as well as the full exception details, as returned by its ToString
method) when the SecurityException is thrown, I may be able to suggest a
workaround.
2. Since you're targeting version 2.0 of the .NET Framework, you could
perhaps switch from a control to a ClickOnce application. Obviously, this
will change the user's interaction with the application, so the resulting
user experience may or may not be acceptable.
> 4. Modifying the application code: I've tried to request / assert
> permissions at the start of procedures that access the file system.
> Presumably this doesn't work because the permission should be requested
> by a more trusted assembly etc.
Permission demands are what cause security exceptions (when the demand
fails), not a mechanism for avoiding them. Assertion would be the
appropriate technique, but your code can only successfully assert a
permission it actually possesses (and only if it's also been granted
permission to make assertions in the first place), so it won't work here
either since your code won't be able to successfully assert the permission
it's missing.
danieljlord@hotmail.com - 23 Jan 2006 09:00 GMT
Nicole, thank you very much for all your help on this.