Xbap and standalone applications in Vista.
I came across some errors while developing wpf applications in vista. So I have a couple of questions. I would appreciate anybody who makes an effort to go through them and answer. I have tried to document what I tried in some detail.
Question 1
- I created an xbap (formerly known as WBA) application using a standard template provided in VS 2005.Hit F5 to start application with debugging, so my xbap application launches within IE. This is the expected behaviour. Until this point everything looks good.
- Go to the bin\debug inside my project directory and double click on the xbap application there. I get an error message. Well this no the expected behaviour.
- "Application cannot be downloaded. Check for network connectivity or contact the applicatio publisher for assistance."
- Right click on the project in the solution explorer and publish it with the default settings. Go to the publish folder inside project directory and double click on the xbap application there, this time the applicatoin launches in IE.
- Now if I go back to bin\debug and double click on xbap application it launches in IE. This is because it takes from the cache. If I delete the cache and try launching the xbap in bin\debug it gives me the same error.
- I tried this on Vista builds for MAY and June CTP.
- Now here is something interesting, I tried steps 1 and 2 on Windows 2003 server machine which had Feb CTP for WinFx Runtime Beta 2. So when I do step 2 the launches as expected.
Does any body have an idea why this happening? Is it because of an issue with above mentioned vista builds or does it have something to do with IIS 7.0 beta which comes with vista( I have IIS 6 on Windows 2003 server)?
Question 2
If we try to convert a xbap application created using the standard template in VS 2005 to a standalone application, we can do so by changing just one line in the .csproj file(Change the HostInBrowser value to false).I tried changing back to a xbap application by changing the HostInBrowser value to true. I tried it both ways and it works fine.
However if I try to create standalone application using a standard template in VS2005 and then try changing it to a xbap application (following the steps mentioned above) it does not work as expected. In fact the application does not build anymore in VS.
So the question is Can we change an xbap application to standalone app and vice versa only if we use a standard template for xbap application (to create an application). Is it possible to do it (change a standalone app to xbap application and vice versa) when we use a std template for standalone app? In fact I comapred the two project files (xbap and standalone as created by VS) and then tried to make the .csproj for standalone closer to the xbap .csproj file. I did not work though.
[3025 byte] By [
Sajiv] at [2007-12-23]
Re #1: I don't think that IIS6 or 7 have anything to do with these issues you see when you shell-activate your XBAP. Do you have PublishUrl or UpdateUrl set in your project file? That seems a likely cause because, during deployment, the location pointed to by your manifest (keyed off of those properties) decides where the app binaries are downloaded from. There is no known issue with shell activation of XBAPs on Vista, either. I use Vista primarily and haven't seen the issues you're reporting.
Re #2: It is easier to switch from an XBAP to a standalone app, on several fronts: the default Internet zone permission set enjoyed by XBAPs is a subset of the full trust permissions enjoyed by traditional standalone apps, so you're moving from a more restrictive to a less restrictive model. Further, because XBAPs use the Page-based model with its implicit Navigation window, moving to a standalone window model is easy. The reverse is tricky because traditional standalone apps use Window and that is not supported in the partial trust sandbox. So if you code your standalone app to use Pages instead, the transition is so much easier. Besides these, I can't think of any hurdles to switching between these app flavors. But it doesn't end there. The debugging story within VS is different for these app types. So is the publishing story. For example, there are specific project properties for StartProgram and StartArguments in XBAP projects that tell VS to launch PresentationHost with the right args so XBAPs may be debugged. Karen has created a flexible template that attempts to make this switch easier on developers.
Thank you for the quick response.
Re #1: I will try to rephrase my question.
- Create xbap application using std template in VS 2005.
- Build the project in VS.
- Go to bin\debug double click on the xbap. This throws an error
What could be the problem?
(The error was: System.Deployment.Application.DeploymentDownloadException (Unknown subtype)
- Downloading file:///D:/TESTS/....../bin/Debug/WinFxBrowserApplication1.exe.deploy did not succeed.)
Re #2: That makes sense. I had reached the same conclusion.So here's what I tried:
- Create a standalone app using std template in VS. It builds fine.
- Change HostInBrowser value to true and Install to false. Set TargetZone to Internet.
- Used page(s) instead of window(s)
- Remove the follwing references in the .csproj file
- <Reference Include="System.ServiceModel" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.IdentityModel" />
<Reference Include="ReachFramework" />
- Build the app. I get the follwing error.
Error 1 The ClickOnce manifest for XAML Browser Applications must always be signed. You must specify properties: SignManifests (value set to True), ManifestKeyFile (with the name of your key file) and ManifestCertificateThumbprint (hexadecimal thumbprint value in SHA-1 format, of key file). Alternatively, you may use your IDE's Publish Wizard or Signing options. WindowsApplication1
Is there anything else that I am missing?
BTW, is this flexible template going to be std template (provided by MS) available with VS?
We might have a similar need to #2. However, what I would want to do is grab certain "windows" out of the standalone app and have them appear in an xbap application.
From the discussion, it appears that even with the flexible template, we would need to compile separate versions for xbap and standalone. Suppose I put all the windows to be shared between in xbap and standalone into one assembly built with a flexible template. Should it be as simple as recompiling it with different options to get an assembly to use with each version?
Issue #1 is solved.I was working on May and June CTPs of vista when I got the error. I am using July CTP of Vista this time (I dont know if that helps in anyway).
Adding windows to the xbap app may not work. Actually it should not because windows are not supported in partial trust sandbox.
#2 Still working on it. I think the template will be useful if it restricts us to adding functionality that is available to both types of apps(i.e. functionality available in partial trust sandbox).
BTW I downloaded the flexible template, my first impression is that it stresses on using the page model for building apps.
For the signing issues in #2, look for properties SignManifests, ManifestCertificateThumbprint and ManifestKeyFile in the project. There's also an Item like <None Include="MyXbap_TemporaryKey.pfx" />.
All ClickOnce-deployed apps must have their manifests signed. This is because ClickOnce enforces manifest signature validation during deployment. This is done for you by the project and build system in case of XBAPs. When your XBAP project is created, the project system creates a certificate for it, adds the cert to your cert store (I believe this is optional), adds these 3 properties and 1 item to the project. In case of standalone apps, the default behavior is to not create the manifests in the first place, so no signing-related tasks happen on project creation. You can try moving these properties, item and the PFX file over to the standalone app's project.
If you do not want a ClickOnce-deployed standalone app, you can simply remove the GenerateManifests property from the project and launch the app via the exe.
I tried to follow your suggestion
Added the three properties, the item (<None Include="MyXbap_TemporaryKey.pfx" />) and also the pfx file to the project. This time it builds fine and xbap launches without any problems when you dbl. click on it.
Thank You for follwing up.
I would like to list the steps followed to manually convert a standalone application to a XBAP.
- Change HostInBrowser to true install to false. Set TargetZone to Internet.
- Remove the follwing references in the .csproj file
- <Reference Include="System.ServiceModel" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.IdentityModel" />
<Reference Include="ReachFramework" />
- Add the following properties Sign Manifests, ManifestCertificateThumbprint and ManifestKeyfile to the project file. e.g.
<SignManifests>True</SignManifests>
<ManifestKeyFile>WinFxBrowserApplication1_TemporaryKey.pfx</ManifestKeyFile>
<ManifestCertificateThumbprint>1B4892D18134382E2E6280912EBF840B38FFD138</ManifestCertificateThumbprint>
- Add an item to the project file, e.g.
<None Include="WinFxBrowserApplication1_TemporaryKey.pfx" />
- Add (copy) the pfx file to project directory and build. We are ready to launch the app.
#We can take a look at these properties and item in step 3 and 4 by opening up the project file (say using notepad) of a xbap app created using the std. template provided in VS. There we get an idea as to how we can add (configure) these properties and item in our standalone app.
# We may have windows in our app (the project will build without any problems), however we cannot launch them when the app is coverted to an xbap. So we need to make care that we are not luanching any windows in the xbap version of the app. Also functionality outside the sandbox will not be available.