yeatd

Hi All,

I am writing a dual XBAP/standalone application. I have a separate project for each, but both call a core assembly that actually contains the UI and main application logic.

I have the standalone application working OK, but the XBAP is causing me a problem - every time I run it it can't find my main page.

Here is a short and edited version of my main application. I think the problem is the creation of the Uri that I assign to
this.StartupUri. I am not sure that I have the pack formatting correct

Can you actually do this in an XBAP

App.xaml:
<Application x:Class="MyApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Startup="App_Startup"/>

App.xaml.cs:

void App_Startup(object sender, StartupEventArgs args)
{
this.DispatcherUnhandledException += this.App_DispatcherUnhandledException;

this.Resources = new OfficeStyle();

if (BrowserInteropHelper.IsBrowserHosted)
{
this.StartupUri = new Uri(@"pack://application:,,,/
MyAssemblyName;component/MainPage.xaml");
}
else
{
Window mainWindow = new Window();
this.MainWindow = mainWindow;
mainWindow.Content = new
MyAssembly.MainPage();
mainWindow.Show();
}
}


Can anyone point me in the right direction please

Thanks!



Re: Windows Presentation Foundation (WPF) Calling pages in external assemblies

Michael.Weinhardt - MSFT

Hi,

What happens if you try the following:

this.StartupUri = new Uri(@"pack://application:,,,/MainPage.xaml");

Cheers,

Michael





Re: Windows Presentation Foundation (WPF) Calling pages in external assemblies

yeatd

Hi Michael,

I tried your suggestion and I get the following:

Startup URI: C:\Dougal\Client\Dougal.Client.WebApp\bin\Debug\Dougal.Client.WebApp.xbap
Application Identity: file:///C:/Dougal/Client/Dougal.Client.WebApp/bin/Debug/Dougal.Client.WebApp.xbap#Dougal.Client.WebApp.xbap, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1965adc34fbf0403, processorArchitecture=msil/Dougal.Client.WebApp.exe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1965adc34fbf0403, processorArchitecture=msil, type=win32

System.IO.IOException: Cannot locate resource 'mainpage.xaml'.
at Dougal.Client.WebApp.App.App_DispatcherUnhandledException(Object sender, DispatcherUnhandledExceptionEventArgs e)
at System.Windows.Threading.Dispatcher.CatchException(Exception e)
at System.Windows.Threading.Dispatcher.CatchExceptionStatic(Object source, Exception e)
at System.Windows.Threading.ExceptionWrapper.CatchException(Object source, Exception e, Delegate catchHandler)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.StartDispatcherInBrowser(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)


-----------------------

PresentationHost.exe v3.0.6920.0 (vista_rtm_wcp.061020-1904) - c:\WINDOWS\system32\PresentationHost.exe
ntdll.dll v5.1.2600.2180 (xpsp_sp2_rtm.040803-2158) - C:\WINDOWS\system32\ntdll.dll
kernel32.dll v5.1.2600.3119 (xpsp_sp2_gdr.070416-1301) - C:\WINDOWS\system32\kernel32.dll
ADVAPI32.dll v5.1.2600.2180 (xpsp_sp2_rtm.040803-2158) - C:\WINDOWS\system32\ADVAPI32.dll
RPCRT4.dll v5.1.2600.2180 (xpsp_sp2_rtm.040803-2158) - C:\WINDOWS\system32\RPCRT4.dll
USER32.dll v5.1.2600.3099 (xpsp_sp2_gdr.070308-0222) - C:\WINDOWS\system32\USER32.dll
GDI32.dll v5.1.2600.3099 (xpsp_sp2_gdr.070308-0222) - C:\WINDOWS\system32\GDI32.dll
msvcrt.dll v7.0.2600.2180 (xpsp_sp2_rtm.040803-2158) - C:\WINDOWS\system32\msvcrt.dll
ole32.dll v5.1.2600.2726 (xpsp_sp2_gdr.050725-1528) - C:\WINDOWS\system32\ole32.dll
SHELL32.dll v6.00.2900.3051 (xpsp_sp2_gdr.061219-0316) - C:\WINDOWS\system32\SHELL32.dll
SHLWAPI.dll v6.00.2900.2995 (xpsp.060913-0019) - C:\WINDOWS\system32\SHLWAPI.dll
urlmon.dll v7.00.6000.16473 (vista_gdr.070420-1500) - C:\WINDOWS\system32\urlmon.dll
OLEAUT32.dll v5.1.2600.2180 - C:\WINDOWS\system32\OLEAUT32.dll
iertutil.dll v7.00.6000.16473 (vista_gdr.070420-1500) - C:\WINDOWS\system32\iertutil.dll
WININET.dll v7.00.6000.16473 (vista_gdr.070420-1500) - C:\WINDOWS\system32\WININET.dll
Normaliz.dll v6.0.5441.0 (winmain(wmbla).060628-1735) - C:\WINDOWS\system32\Normaliz.dll
IMM32.DLL v5.1.2600.2180 (xpsp_sp2_rtm.040803-2158) - C:\WINDOWS\system32\IMM32.DLL
comctl32.dll v6.0 (xpsp.060825-0040) - C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03\comctl32.dll
uxtheme.dll v6.00.2900.2180 (xpsp_sp2_rtm.040803-2158) - C:\WINDOWS\system32\uxtheme.dll
MSCTF.dll v5.1.2600.2180 (xpsp_sp2_rtm.040803-2158) - C:\WINDOWS\system32\MSCTF.dll
GameHook.dll v3.30.165 - C:\Program Files\Logitech\SetPoint\GameHook.dll
lgscroll.dll v3.30.165 - C:\Program Files\Logitech\SetPoint\lgscroll.dll
MSVCR80.dll v8.00.50727.762 - C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700\MSVCR80.dll
MSVCP80.dll v8.00.50727.762 - C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700\MSVCP80.dll
NTMARTA.DLL v5.1.2600.2180 (xpsp_sp2_rtm.040803-2158) - c:\WINDOWS\system32\NTMARTA.DLL
WLDAP32.dll v5.1.2600.2180 (xpsp_sp2_rtm.040803-2158) - C:\WINDOWS\system32\WLDAP32.dll
SAMLIB.dll v5.1.2600.2180 (xpsp_sp2_rtm.040803-2158) - c:\WINDOWS\system32\SAMLIB.dll
CLBCATQ.DLL v2001.12.4414.308 - c:\WINDOWS\system32\CLBCATQ.DLL
COMRes.dll v2001.12.4414.258 - c:\WINDOWS\system32\COMRes.dll
VERSION.dll v5.1.2600.2180 (xpsp_sp2_rtm.040803-2158) - C:\WINDOWS\system32\VERSION.dll
xpsp2res.dll v5.1.2600.2180 (xpsp_sp2_rtm.040803-2158) - c:\WINDOWS\system32\xpsp2res.dll
Secur32.dll v5.1.2600.2180 (xpsp_sp2_rtm.040803-2158) - c:\WINDOWS\system32\Secur32.dll
ws2_32.dll v5.1.2600.2180 (xpsp_sp2_rtm.040803-2158) - c:\WINDOWS\system32\ws2_32.dll
WS2HELP.dll v5.1.2600.2180 (xpsp_sp2_rtm.040803-2158) - c:\WINDOWS\system32\WS2HELP.dll
dfshim.dll v2.0.50727.1318 (redbitsb1.050727-1300) - c:\WINDOWS\system32\dfshim.dll
mscoree.dll v2.0.50727.1318 (redbitsb1.050727-1300) - c:\WINDOWS\system32\mscoree.dll
mscorwks.dll v2.0.50727.1318 (redbitsb1.050727-1300) - C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
PresentationHostDLL.dll v3.0.6920.0 (vista_rtm_wcp.061020-1904) - c:\WINDOWS\Microsoft.Net\Framework\v3.0\WPF\PresentationHostDLL.dll
mscorlib.ni.dll v2.0.50727.1318 (redbitsb1.050727-1300) - C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\7200ab3f147a2be5ce88ec094c16d8d5\mscorlib.ni.dll
System.ni.dll v2.0.50727.1318 (redbitsb1.050727-1300) - C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System\e931b1dad864c9407cf91f1418028a0c\System.ni.dll
WindowsBase.ni.dll v3.0.6920.0 (vista_rtm_wcp.061020-1904) - C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\WindowsBase\f208956b326fef37aacfafdd0cf2102a\WindowsBase.ni.dll
PresentationCore.ni.dll v3.0.6920.0 (vista_rtm_wcp.061020-1904) - C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\PresentationCore\266c25ab6ad9d2d686a9d5e956a34434\PresentationCore.ni.dll
PresentationFramework.ni.dll v3.0.6920.0 (vista_rtm_wcp.061020-1904) - C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\PresentationFramewo#\a441f40237b49e2b3408c84de5e53b05\PresentationFramework.ni.dll
msctfime.ime v5.1.2600.2180 (xpsp_sp2_rtm.040803-2158) - C:\WINDOWS\system32\msctfime.ime
actxprxy.dll v6.00.2900.2180 (xpsp_sp2_rtm.040803-2158) - C:\WINDOWS\system32\actxprxy.dll
msi.dll v3.1.4000.4039 - c:\WINDOWS\system32\msi.dll
SXS.DLL v5.1.2600.3019 (xpsp_sp2_gdr.061019-0414) - c:\WINDOWS\system32\SXS.DLL
ieproxy.dll v7.00.5730.11 (winmain(wmbla).061017-1135) - C:\Program Files\Internet Explorer\ieproxy.dll
System.Configuration.ni.dll v2.0.50727.1318 (redbitsb1.050727-1300) - C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System.Configuration\8757d0ebbdd0ae5d5de84f52ec8f4022\System.Configuration.ni.dll
System.Xml.ni.dll v2.0.50727.1318 (redbitsb1.050727-1300) - C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System.Xml\1fdf4d95f8264261b8ed74de1f354542\System.Xml.ni.dll
rsaenh.dll v5.1.2600.2161 (xpsp.040706-1629) - c:\WINDOWS\system32\rsaenh.dll
shfolder.dll v6.00.2900.2180 (xpsp_sp2_rtm.040803-2158) - c:\WINDOWS\system32\shfolder.dll
PresentationUI.ni.dll v3.0.6920.0 (vista_rtm_wcp.061020-1904) - C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\PresentationUI\63b1b4bfca7870c76be63e8b117dc176\PresentationUI.ni.dll
mslbui.dll v5.1.2600.2180 (xpsp_sp2_rtm.040803-2158) - C:\WINDOWS\system32\mslbui.dll
System.Drawing.ni.dll v2.0.50727.1318 (redbitsb1.050727-1300) - C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System.Drawing\a64482525a63334e261609b8d352bc05\System.Drawing.ni.dll
mscorjit.dll v2.0.50727.1318 (redbitsb1.050727-1300) - C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorjit.dll
PresentationFramework.Royale.ni.dll v3.0.6920.0 (vista_rtm_wcp.061020-1904) - C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\PresentationFramewo#\27543565d9d51acf217c56e3048e4124\PresentationFramework.Royale.ni.dll
Assergs.Windows.dll v1.0.0.0 - C:\Documents and Settings\darren.yeates\Local Settings\Apps\2.0\5BPZ5BJK.7BJ\7834VNNY.70H\doug..xbap_1965adc34fbf0403_0001.0000_7646f3f78f38cc6c\Assergs.Windows.dll
Dougal.ClientCore.dll v1.0.0.0 - C:\Documents and Settings\darren.yeates\Local Settings\Apps\2.0\5BPZ5BJK.7BJ\7834VNNY.70H\doug..xbap_1965adc34fbf0403_0001.0000_7646f3f78f38cc6c\Dougal.ClientCore.dll
diasymreader.dll v8.0.50727.1318 (redbitsb1.050727-1300) - C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\diasymreader.dll

the actual MainPage.xaml lives within Dougal.ClientCore.dll





Re: Windows Presentation Foundation (WPF) Calling pages in external assemblies

Chango V. - MSFT

What exactly is the problem with the code you showed originally

How is MyAssemblyName[.dll] deployed relative to the XBAP