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

.NET Framework4.8函数迁移V4 isolated遇FileNotFoundException求助

解决方案

1. 核对项目文件配置

先把项目文件里的配置捋一遍,确保没漏关键项:

  • 确认<TargetFramework>net8.0</TargetFramework>和<OutputType>Exe</OutputType>已经设对
  • 必须加上<AzureFunctionsVersion>v4</AzureFunctionsVersion>
  • 把dotnet-isolated需要的NuGet包都加上,别漏了触发器对应的包,比如:
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.20.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.16.0" />
    <!-- TimerTrigger用这个 -->
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.3.0" />
    <!-- ServiceBusTrigger用这个 -->
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.13.0" />
    
  • 在<PropertyGroup>里加<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>,防止清理过程把必要文件删了

2. 检查函数注册逻辑

dotnet-isolated模式下,函数得手动注册,不能靠自动发现:

  • 项目里必须有Program.cs,代码得是这样的:
    using Microsoft.Extensions.Hosting;
    
    var host = new HostBuilder()
        .ConfigureFunctionsWorkerDefaults()
        .Build();
    
    host.Run();
    
  • 每个函数类都得标[Function("你的函数名")]特性,方法签名要符合isolated要求,比如得带FunctionContext参数,返回Task或者具体类型

3. 彻底清理重建

别直接点生成,先执行这一套命令:

dotnet clean
dotnet restore
dotnet build --configuration Release
  • 也可以直接删掉项目目录下的bin和obj文件夹,再重新生成

4. 检查输出目录文件

生成后去输出目录(比如bin/Release/net8.0)看看:

  • 有没有对应的dll文件(如果原项目不是叫Functions,那应该是你的项目名称.dll,别死盯着Functions.dll)
  • 确保functions.exe和这个dll在同一个目录里
  • 要是还是有问题,用dotnet publish生成完整发布包,再运行发布后的文件试试

5. 确认本地运行环境

  • 检查Azure Functions Core Tools版本,得是v4.x,用func --version就能看
  • 别直接双击functions.exe启动,要用func start命令,isolated模式得靠Functions Host托管运行

内容的提问来源于stack exchange,提问作者Javi Kroonenburg

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 13:55:14