How can I use WF within an XBAP?

Over the past few weeks I've had a few people ask about how to use WF in an XBAP project. I wanted to share the results of the conversations. It's pretty interesting using XAML for UI and XAML for business logic in one application. WF allows for developing business logic declaratively as XAML and XBAP is a low install footprint form of a WPF user interface which allows for developing user interface declaratively as XAML.

The trouble with using WF inside an XBAP application is that WF requires full trust and XBAP usually requires partial trust DLL's only.

So we need to use full trust in an XBAP application in order to use WF in it. Here's two suggested solutions. (1) This is actually pretty easy if you are in a corporate intranet environment where you can create a software signing certificate and load it into the active directory. Just sign your XBAP application with that and you can use full trust and hence WF. The users IE browser will pick up the certificate and by this means IE will allow WF to run in full trust.

(2) If you require parts of the WF engine to run in the XBAP software but you do not have control over an active directory environment you should consider Click Once software deployment for a stand-alone application. Because this doesn't run inside IE it can run with full trust. You still want to use click-once deployment allowing for web click from a URL to running in one go. The application could also take the look of a browser window.

So there's two ways to avoid partial trust with an XBAP application to allow WF use. There's also a good discussion of XBAPs here, check the comments.