PhotoBrowser Sample generates Security Exception

Topics: Developer Forum, User Forum
Sep 9, 2007 at 2:31 PM
I built the PhotoBrowser sample and when I go to run the *.exe, I get the Security Exception below. How do I fix it?

System.Security.SecurityException was unhandled
Message="Request for the permission of type 'System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
Source="mscorlib"
StackTrace:
at System.Reflection.Assembly._GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at System.Reflection.Assembly.GetType(String name)
at System.Windows.Markup.BamlMapTable.GetTypeFromTypeInfo(BamlTypeInfoRecord typeInfo)
at System.Windows.Markup.BamlMapTable.GetTypeFromId(Int16 id)
at System.Windows.Markup.BamlRecordReader.GetElementAndFlags(BamlElementStartRecord bamlElementStartRecord, Object& element, ReaderFlags& flags, Type& delayCreatedType, Int16& delayCreatedTypeId)
at System.Windows.Markup.BamlRecordReader.BaseReadElementStartRecord(BamlElementStartRecord bamlElementRecord)
at System.Windows.Markup.BamlRecordReader.ReadElementStartRecord(BamlElementStartRecord bamlElementRecord)
at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord)
at System.Windows.Markup.BamlRecordReader.Read(Boolean singleRecord)
at System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment()
at System.Windows.Markup.TreeBuilder.Parse()
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc)
at MS.Internal.AppModel.AppModelKnownContentFactory.BamlConverter(Stream stream, Uri baseUri, Boolean canUseTopLevelBrowser, Boolean sandboxExternalContent, Boolean allowAsync, Boolean isJournalNavigation, XamlReader& asyncObjectConverter)
at MS.Internal.AppModel.MimeObjectFactory.GetObjectAndCloseStream(Stream s, ContentType contentType, Uri baseUri, Boolean canUseTopLevelBrowser, Boolean sandboxExternalContent, Boolean allowAsync, Boolean isJournalNavigation, XamlReader& asyncObjectConverter)
at System.Windows.Navigation.NavigationService.GetObjectFromResponse(WebRequest request, WebResponse response, Uri destinationUri, Object navState)
at System.Windows.Navigation.NavigationService.DoNavigate(Uri source, NavigationMode f, Object navState)
at System.Windows.Navigation.NavigateQueueItem.Dispatch(Object obj)
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)
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.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at PhotoBrowser.App.Main()
InnerException:
Sep 22, 2007 at 5:23 PM
Whats the OS,

whats your perm run level.

looks to be a failure to actually get perm levels? not expert on this....

Message="Request for the permission of type 'System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."

More underlying info would be a big boon to anyone giving assistance.
Sep 22, 2007 at 6:53 PM
The OS is Win XP Pro SP2 with all latest patches.

.Net 1.1, 2.0. 3.0 and 3.5

I am an Administrator on this machine.

I don't know what more I can tell you that would help.
Sep 23, 2007 at 12:17 AM
Edited Sep 23, 2007 at 6:19 AM
ok. I believe this is a trust issue.

Express applications require that all objects running can run in “Internet
Security Zone”.

When they encounter Internet Zone security (or less than full trust anywho) they crash with EXACTLY the same error

I am GUESSING that the full-trust model is somehow not being implemented/instantiated/or accepted due to settings on the machine???

(check in the Security section of the project properties in Visual Studio).

For some permissions, most likely your XBAP has to be full trust. In order for it to run, you have to add the signing certificate to the clients' Trusted Publishers store. More information: http://msdn2.microsoft.com/en-us/library/01daf08f.aspx.

Ill go build it and have a look


Thats the best that I can do.
HTH
Sep 23, 2007 at 3:53 PM
OK, How do I fix the “Internet Security Zone” problem that you mention?

THANKS for the Help.
Sep 30, 2007 at 7:37 PM
Hi mate,

I cant reproduce this issue,

I can confirm that the message is security related :\ not much help eh...

I am sorry I cant be more forthcoming.

Guessing wildly I am thinking that the "Go Authenticate for the piccies" section is causing the issue after reading the code...

All I can suggest is ripping down the code until it builds and identifying the culprit.
HTH

Si.