MagdaS

Hello,

I am having some difficulties publishing the project I am working on the web. When I change in .csproj file the HostInBrowser property to true and try to publish to localhost I get 2 errors:

Error: Failed to copy file 'D:\StandaloneBrowserApp\bin\Debug\StandaloneBrowserApp.publish\StandaloneBrowserApp.application' to 'http://localhost/MyBap/StandaloneBrowserApp.application'. Unable to add 'StandaloneBrowserApp.application' to the Web. Unable to add file 'StandaloneBrowserApp.application'. The system cannot find the file specified.

Error: Failed to copy file 'D:\StandaloneBrowserApp\bin\Debug\StandaloneBrowserApp.publish\StandaloneBrowserApp.application' to 'http://localhost/MyBap/StandaloneBrowserApp_1_0_0_0.application'. Unable to add 'StandaloneBrowserApp_1_0_0_0.application' to the Web. Unable to add file 'StandaloneBrowserApp_1_0_0_0.application'. The system cannot find the file specified.


When I look in the compilation output directory, I see that it did not create the deployment manifest (i.e., .application) file. This is why it can't be copied...it doesn't exist. I've tried several ways to fix this but I am out of ideas. Maybe it has something to do with my system: I run on Windows XP with .NetFramework 2.0.

Any ideas are welcomed...

Thanks,

Magda


Re: Windows Presentation Foundation (WPF) Publish xbap problem

Laurent Bugnion

Hi,

Try two things:

1) Clean your solution before you build again (Menu "Build / Clean Solution")

2) Increase the Publish version number from "1.0.0.0" to "1.0.0.1".

Greetings,
Laurent





Re: Windows Presentation Foundation (WPF) Publish xbap problem

MagdaS

Hi, thanks, I've tried to clean solution and then increase version no manually, but it didn't worked... I don't understand why when I create a standalone installer it creates the .application file but for web wouldn't do it...




Re: Windows Presentation Foundation (WPF) Publish xbap problem

Chango V. - MSFT

There are more steps to manually converting a project to become an XBAP: http://www.charlespetzold.com/blog/2006/11/120718.html






Re: Windows Presentation Foundation (WPF) Publish xbap problem

Matt Galbraith

I believe you're hitting an issue fixed in the .NET 3.5 release. Recreating the project from the browser-application template might fix this, but there were definitely some issues with .xbap publishing in RTM.

However, when building an .xbap, you dont actually need to publish the application (at least on the 3.0 release). Since .xbaps don't have the concept of DeploymentProvider (one of the important values set during publish) then can simply be copied from the bin\release(or debug) folder to your server's share.

If you're still interested in getting publish to work, please reply with the topmost two <ItemGroup> tags from your .proj file. There might be something that can be done to work around the issue. I dont have 3.0 on any of my machines at the moment but this scenario definitely works in 3.5 (change HostInBrowser, Change Install, then Publish). You'll hit other issues if you want your converted .xbap to be partial trust though... by default the converted app will create a new window, which is a no-no in the internet zone.

HTH,

Matt Galbraith






Re: Windows Presentation Foundation (WPF) Publish xbap problem

MagdaS

Hi and thanks for the answer. I did installed .NET 3.5 and now it does work if I copy the files to wwwroot. My only problem with this is a trust not granted issue which I guess it has something to do with the certificates.

It would be nice tho to be able to publish the application: I still get those two errors when trying to publish....Here are the first tags from my .csproj:

<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Web.Services" />
etc...

I hope thats what you were refering to...

Magda






Re: Windows Presentation Foundation (WPF) Publish xbap problem

Matt Galbraith

Whoops, I meant the intial PropertyGroup.. specifically whichever group has the <HostInBrowser>, <Install>, <GenerateManifests>.

An alternate thing to try would be to start with a standard WPF app project, apply your changes to it to make it an .xbap, then post what steps it took to get the project un-publishable. That way I can do them myself and suggest the appropriate fixes... since I can't get this reproing on 3.5 bits.

As for your Trust Not Granted issue on deployment from a non-local path, this indicates that you have configured the .xbap for full trust. Your signing certificate needs to have entries in Trusted Root Certificate Authorities and Trusted Publishers for this scenario to work. Ideally you can make your app work as an Internet-zone app, which will allow it to deploy from any path. ( <TargetZone>Internet</TargetZone> in Proj file, or use the VS UI ) If you're using a WPF app converted from a standalone app to a browser app, you'll want to make your .xaml file specified as your StartupUri (in App.Xaml by default) have a Page (or similar) element as the root instead of Window or NavigationWindow. To prevent popup window creation from the internet zone, standalone windows are blocked from the internet zone and will throw a security exception when created.

Hope this helps,

Matt






Re: Windows Presentation Foundation (WPF) Publish xbap problem

MagdaS

The trust not granted issue I managed to solve exactly how you said, the problem is that the certificate has to be installed manually: downloaded from the server, and the added in Trusted Root Certificate Authorities and Trusted Publishers. Maybe there is another way If I try with partial trust I hit another problem: it opens the login page but then after login I get a security problem: System.Security.SecurityException was unhandled
Message: Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

I think for an application normal would be that when the user is openening the application for the first time to have the oportunity to accept the certificate and the install the application...And I think if I manage to publish the project the behavior will be something similar with what i described (I am new to this kind of web development...so that's why I am not sure).

The beggining of my .csproj it looks something like this:

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DocumentationFile>
</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
<DefaultClrNameSpace>Stabi</DefaultClrNameSpace>
<AssemblyName>Stabi</AssemblyName>
<OutputPath>bin\$(Configuration)\</OutputPath>
<AlwaysCompileMarkupFilesInSeparateDomain>false</AlwaysCompileMarkupFilesInSeparateDomain>
<OutputType>WinExe</OutputType>
<HostInBrowser>True</HostInBrowser>
<TargetZone>Internet</TargetZone>
<StartAction>Program</StartAction>
<StartProgram>$(WINDIR)\System32\PresentationHost.exe</StartProgram>
<ApplicationExtension>.xbap</ApplicationExtension>
<StartArguments>-debug "$(MSBuildProjectDirectory)\bin\$(Configuration)\$(AssemblyName)$(ApplicationExtension)"</StartArguments>
<SignManifests>true</SignManifests>
<ManifestKeyFile>Stabi_TemporaryKey.pfx</ManifestKeyFile>
<ManifestCertificateThumbprint>A14042FB5010ABCBE2E73A0E5D5765D22ADCA6F7</ManifestCertificateThumbprint>
<RootNamespace>Stabi</RootNamespace>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ProjectGuid>{212E8675-58A9-4B84-ABD8-D024E8868948}</ProjectGuid>
<GenerateManifests>true</GenerateManifests>
<StartupObject>
</StartupObject>
<IsWebBootstrapper>true</IsWebBootstrapper>
<SignAssembly>false</SignAssembly>
<PublishUrl>C:\Inetpub\wwwroot\test\</PublishUrl>
<Install>false</Install>
<InstallFrom>Web</InstallFrom>
<UpdateEnabled>true</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<InstallUrl>http://localhost/test/</InstallUrl>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<BootstrapperEnabled>true</BootstrapperEnabled>
<ExcludedPermissions>
</ExcludedPermissions>
<AssemblyOriginatorKeyFile>Stabi_TemporaryKey.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>

I'll try what you suggested and see how it behaves....

Magda






Re: Windows Presentation Foundation (WPF) Publish xbap problem

Matt Galbraith

Hi Magda,

I tried tweaking with all the tags that are "unusual" for an .xbap (such as "Update*") but I was unable to repro your publish problem on VS 2008 (don't have 2005 around at the moment). I suspect this is a bug that was fixed between the two releases.

As for your partial-trust issues, ideally you will want to get your application to run from the internet zone. The security exception you're seeing stems from your code doing some action that is disallowed in partial trust. There is no automated way to add your security certificate to the user's store, so unless you absolutely need it I strongly advise against going the full-trust .xbap route.

First, read up on CAS a bit... there's lots of references online. Here's one I randomly found. Next, when you converted this app from a standalone app, at a bare minimum you need to change the startup class from Window or NavigationWindow to Page... on a plain vanilla app this is the only thing needed to get the app running in partial trust. If you've run the .xbap from outside VS before, open an SDK command prompt and run mage.exe -cc to make sure you aren't running a stale copy of the app.

Finally, once you've done this part, you'll need to figure out what other stuff you might be doing in your app that is not allowed in partial trust. Set your debugger to break on first-chance security exceptions... sometimes these are easy to understand and sometimes quite cryptic. See the online resources for CAS to figure out what sorts of things will not be allowed from the Internet zone for WPF. (Creating windows, accessing the file system, accessing the web on sites other than the site of origin, bitmapeffects, unmanaged code, etc). Come back here and ask any questions (I suggest creating a separate topic so people arent confused by the title) about partial-trust issues you hit.

HTH,

Matt