Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Mark of the Web" prevents Windows app from running when distributed as a ZIP file #1890

Open
rmartin16 opened this issue Jun 27, 2024 · 1 comment
Labels
bug A crash or error in behavior. windows The issue relates to Microsoft Windows support.

Comments

@rmartin16
Copy link
Member

Describe the bug

When a ZIP-packaged app is extracted and runs, a stacktrace is shown when loading DLLs fails (as seen in #1881).

This first happens when pythonnet tries to load its Python runtime DLL (Python.Runtime.dll) and then for the WebView DLL from toga-winforms.

The underlying issue is Windows' Mark of the Web (MotW) functionality that prevents running foreign code while the file is marked.

Steps to reproduce

Package an app for Windows using ZIP. Extract and run that app on another machine.

Expected behavior

The app should successfully run.

The issue can be worked around by manually removing the MotW from all DLLs in the app (via selecting "Unblock" in the DLL file's properties).

To bypass the MotW check automatically, we can tell the .NET runtime to allow loading remote sources.

This can be accomplished via a <App Formal Name>.exe.config file alongside the app's stub exe:

<configuration>
   <runtime>
      <loadFromRemoteSources enabled="true"/>
   </runtime>
</configuration>

Since this is not needed for MSI packages, it may be best to add this file only when packaging as a ZIP.

Screenshots

No response

Environment

  • Operating System: Windows 11
  • Python version: 3.11
  • Software versions:
    • Briefcase: 0.3.20.dev15+g93ee7e9f

Logs

No response

Additional context

No response

@rmartin16 rmartin16 added bug A crash or error in behavior. windows The issue relates to Microsoft Windows support. labels Jun 27, 2024
@freakboy3742
Copy link
Member

Given how simple the file is, it should be possible to inject this directly into the zip file at time of packaging without ever writing a file to disk.

However, before we do that, I'd like to understand what else this file is used for. If there's any possibility we might want to use it for any other app configuration, we might want to add it earlier in the build process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior. windows The issue relates to Microsoft Windows support.
Projects
None yet
Development

No branches or pull requests

2 participants