System.Security.SecurityException

One of my users reported this exception when running the wyUpdate.exe:

************** Exception Text **************System.Security.SecurityException: System.Security.Permissions.SecurityPermission at wyDay.Controls.Windows7Taskbar.get_TaskbarList() at wyDay.Controls.Windows7Taskbar.SetProgressValue(IntPtr hwnd, UInt64 current, UInt64 maximum) at wyDay.Controls.Windows7ProgressBar.set_ShowInTaskbar(Boolean value) at wyUpdate.PanelDisplay.ChangePanel(FrameType panType, String title, String description, String body, String bottom) at wyUpdate.frmMain.ShowFrame(Frame frameNum) at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)The type of the first permission that failed was:System.Security.Permissions.SecurityPermissionThe demand was for:<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"version="1"Flags="UnmanagedCode"/>

The Zone of the assembly that failed was:MyComputer

Thank you for a great product.

Best Regards.

, edited

This is a problem with code access security on your user's machine. Can I ask how you're deploying your applications (MSI, NSIS, InnoSetup, Zip files, etc.) and what type of application you're calling wyUpdate from (ASP.NET app, Win forms app, etc.)?

Also, is your user a consumer or a worker in a corporation?

I am deploying the application with a zip file.

I am calling wyUpdate from a C# app:Process proc = new Process();proc.StartInfo = new ProcessStartInfo(OurDirectory + "\\wyUpdate.exe", "-quickcheck -justcheck -noerr");proc.Start();proc.WaitForExit();int exitCode = proc.ExitCode;proc.Close();if (exitCode == 2){ MessageBox.Show("Updating"); Process.Start(OurDirectory + "\\wyUpdate.exe"); CloseApp();}

The user is a consumer and he/she is the first to report it.

This isn't really a problem with wyUpdate, but rather a problem with .NET CAS (Code Access Security).

Code Access Security is the bane of my existence. It was a broken feature by design - it adds no protection and causes problems like this for users who stumble into it. And now Microsoft finally admits the ineffectiveness of CAS and has eliminated it in .NET 4.0.

But that's a rant for another time.

Here's what's happening: either your users has their computer misconfigured or they're running wyUpdate from a network share. If they're running wyUpdate from a network share, tell them to either [A] run from their local computer or reconfigure their computer to run all .NET apps as "full trust" by default. Also, installing your app using an MSI, NSIS, InnoSetup, or anything other than a zip file will likely also solve this problem. I wish it weren't true, but deploying your app using a zip file causes more problems than it solves.

Thank you Sam for your quick help 🙂