MSDN >
フォーラム ホーム
>
Windows Presentation Foundation (WPF)
>
WindowsFormsHost Problem When Publishing XABP Application
WindowsFormsHost Problem When Publishing XABP Application
- Hello,
In our application we want to play flash(swf) files. We did via windowsformshost control which come in netfx 3.5 help on a component. When you use windowsformshost control in your application you must set security level to "Full Trust" in Security Property of the Project. It's okey. It's working fine but when we want to Publish the Application. We can not do it. We get that error message.
How can we achieve? Let's discus.
Cannot create instance of 'Page1' defined in assembly 'SanalTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error in markup file 'Page1.xaml' Line 1 Position 7.
Line1: "<Page x:Class="SanalTest.Page1"
xmlns="
http://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:x="
http://schemas.microsoft.com/winfx/2006/xaml"Title="Page1" Loaded="Page_Loaded">
sometimes i feel my self like a "." that i am at end of an meaned sentences or begining of it.
回答
- Hi,
You've published a full-trust .xbap but have not mentioned taking the necessary steps to run it from anywhere other than the local file system. Since .xbaps currently cannot ask the end user for elevated trust (i.e. greater than the zone they're coming from in CAS terms), they are either granted it or they refuse. From the description you give, your .xbap is still running in partial trust (since it's allowed to run before it fails) but crashes with a SecurityException when (expectedly) instantiating the WindowsFormsHost conrol. However, given you simply want to show .swf, the WebBrowser control might be all that you need.
Here's some suggestions:
To remotely deploy your .xbap with Full Trust (Once it's actually set that way)
- Export the certificate (.cer) that your application's manifests (.xbap and .exe.manifest) are signed with. Do not distribute .pfx files, as this contains your personal signing key.
- Have anyone who wants to run the app remotely import this .cer to both their Trusted Publishers store and Trusted Root Certification Authorites store (second step only needed for self-generated keys).
To show arbitrary .swf inside your WPF app...
You can probably just use the WebBrowser control (i.e. set the "Source" Property on a Frame control to HTML which wraps the .swf in a full-sized frame. With this approach and passing info to the inner html via URL parameters, any version of .NET can load arbitrary .swf inside a WPF app. With .NET 3.5 Sp1, (see blog post here, not on main MSDN pages yet) you will be able to have some level of interop communication between script running in the HTML and your app, so you could even do things like driving a media-player type element in the HTML.
Hope this helps,
Matt
SDET : Deployment/Hosting- 回答としてマークi-developer 2008年7月1日 8:56
すべての返信
- Hi,
You've published a full-trust .xbap but have not mentioned taking the necessary steps to run it from anywhere other than the local file system. Since .xbaps currently cannot ask the end user for elevated trust (i.e. greater than the zone they're coming from in CAS terms), they are either granted it or they refuse. From the description you give, your .xbap is still running in partial trust (since it's allowed to run before it fails) but crashes with a SecurityException when (expectedly) instantiating the WindowsFormsHost conrol. However, given you simply want to show .swf, the WebBrowser control might be all that you need.
Here's some suggestions:
To remotely deploy your .xbap with Full Trust (Once it's actually set that way)
- Export the certificate (.cer) that your application's manifests (.xbap and .exe.manifest) are signed with. Do not distribute .pfx files, as this contains your personal signing key.
- Have anyone who wants to run the app remotely import this .cer to both their Trusted Publishers store and Trusted Root Certification Authorites store (second step only needed for self-generated keys).
To show arbitrary .swf inside your WPF app...
You can probably just use the WebBrowser control (i.e. set the "Source" Property on a Frame control to HTML which wraps the .swf in a full-sized frame. With this approach and passing info to the inner html via URL parameters, any version of .NET can load arbitrary .swf inside a WPF app. With .NET 3.5 Sp1, (see blog post here, not on main MSDN pages yet) you will be able to have some level of interop communication between script running in the HTML and your app, so you could even do things like driving a media-player type element in the HTML.
Hope this helps,
Matt
SDET : Deployment/Hosting- 回答としてマークi-developer 2008年7月1日 8:56
- Hi,
Your explation was excelent. Thank you so much. We did second way before but we wasn't succesfull. So we tried to did first way which is more securable for everyone.
We Published The Application. We Import the Certifcate into Trusted Pubisher and Trusted Root Cer. from Internet Explorer Tools/Internet Options/Content/ Certificates Tab.
It was successfully. :) Thank you very much.- 編集済みi-developer 2008年7月1日 8:55Solved Problem

