Recent Commits to RefactoringToJQuery:master


Permission error when trying to open a new database connection from an XBAP

If you get the SecurityException below whilst developing an XBAP application

{"Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."} System.Exception {System.Security.SecurityException}

This is because the default security mode for an XBAP is partial trust. The XBAP is sandboxed and has restricted permissions to the file system, database etc. The .NET Framework uses code access security to limit what the XBAP can do. This is kind of consistent with the Flash, Java applets paradigm that XBAP tries to emulate.

It is tempting to assign the application trust via the following mechanism:

In VS2008, do the following:
Double click the VS projects' Properties node containing the XBAP-> Select Properties->Choose the security tab-> Select the option which says "This is a full trust application"->

However this Full Trust permissioning has potential drawbacks that require unpalatable workarounds.

The side effect of the change is that me XBAP can not now be run from a virtual directory or website.

This leaves me to wonder. Is what I need an XBAP, SilverLight application, a standalone XAML application or God forbid an ASP.NET app?

I still want the rich internet application experience and I still want to have a centralised web-like configuration management model. The last thing I want is to be touching each clients' machine to tweak a setting here and a setting there. Because this approach inevitably ends in tears.

I also do not want to implement orthogonal constructs that check for permissions and end up littering the codebase with try/catch blocks that test for permissions.

So in the end after careful consideration of my problem context, SilverLight is the way to go.

No comments:

Test driving ASP.NET MVC 5 with the Entity Framework Code First

The great advantage of MVC Code First is the automated code generation tools. We took a test drive of these features by developing a small ...