You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

本地调试Python Azure Function时无法加载System.Security.Cryptography模块的问题求助

本地调试Python Azure Function时无法加载System.Security.Cryptography模块的问题求助

我已经开发Python Azure Function并本地调试了大概一个月,突然本地调试无法执行func host start,返回以下错误:

Unhandled exception. System.AggregateException: One or more errors occurred. (Unable to load one or more of the requested types.
Could not load file or assembly 'System.Security.Cryptography, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Security.Cryptography, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Security.Cryptography, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Security.Cryptography, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.)
 ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'System.Security.Cryptography, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Security.Cryptography, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Security.Cryptography, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Security.Cryptography, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at Azure.Functions.Cli.ConsoleApp..ctor(String[] args, Assembly assembly, IContainer container)
   at Azure.Functions.Cli.ConsoleApp.RunAsync[T](String[] args, IContainer container)
System.IO.FileNotFoundException: Could not load file or assembly 'System.Security.Cryptography, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Security.Cryptography, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
System.IO.FileNotFoundException: Could not load file or assembly 'System.Security.Cryptography, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Security.Cryptography, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
System.IO.FileNotFoundException: Could not load file or assembly 'System.Security.Cryptography, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Security.Cryptography, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
System.IO.FileNotFoundException: Could not load file or assembly 'System.Security.Cryptography, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Security.Cryptography, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at Azure.Functions.Cli.ConsoleApp.Run[T](String[] args, IContainer container)
   at Azure.Functions.Cli.Program.Main(String[] args)

我的环境信息:

  • Windows 11
  • Python:Windows Store安装的3.11.9版本
  • Azure Functions Extension:1.16.3
  • Azure Functions Core Tools:4.0.5907

我的requirements.txt内容:

azure-functions
pymupdf

我完全不清楚为什么突然出现这个问题,重启没用,不想轻易重置工作电脑。我还尝试修复VS Code安装、重新安装Core Tools,甚至用未修改的HTTP Trigger示例测试,问题依然存在。希望能得到大家的帮助,谢谢!

我已经尝试过的方法:

  • 重启电脑 → 无效
  • 修复VS Code安装 → 无效
  • 卸载并重新安装Azure Core Tools → 无效
  • 删除多余的Python 3.12版本 → 无效果
  • 运行未修改的HTTP Trigger示例 → 问题仍发生
  • 在requirements.txt中添加System.Security.Cryptography及其他变体 → 无效

我找到了System.Security.Cryptography的dll文件,但没找到版本完全匹配的模块——但我之前根本没改动过这个目录,一两周前还能正常运行...

备注:内容来源于stack exchange,提问作者HeatPumpHero

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.13 19:13:05