使用Azure.Storage.Blobs的Dynamics 365注册插件突发故障求助
问题
我开发了一个基于.NET Framework 4.6.2的插件,通过**Azure.Storage.Blobs NuGet包(版本12.17.0)**访问容器内文件夹并下载内容。该插件由一个以“收到HTTP请求”为触发器的云流调用,此前正常运行约3周,现在突然报错:
Could not load file or assembly 'Azure.Storage.Blobs, Version=12.17.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8' or one of its dependencies. The system cannot find the file specified.
项目csproj文件内容如下:
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{EEC7838A-7F97-4D79-9804-E77208AAF255}</ProjectGuid> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Some_Name</RootNamespace> <AssemblyName>Some_Name</AssemblyName> <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> <Deterministic>true</Deterministic> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup> <SignAssembly>true</SignAssembly> </PropertyGroup> <PropertyGroup> <AssemblyOriginatorKeyFile>Some_Name.snk</AssemblyOriginatorKeyFile> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> <Reference Include="Microsoft.CSharp" /> <Reference Include="System.Data" /> <Reference Include="System.Net.Http" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="Some_Name.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <PackageReference Include="Azure.Storage.Blobs"> <Version>12.17.0</Version> </PackageReference> <PackageReference Include="Microsoft.CrmSdk.CoreAssemblies"> <Version>9.0.2.51</Version> </PackageReference> <PackageReference Include="Newtonsoft.Json"> <Version>13.0.3</Version> </PackageReference> </ItemGroup> <ItemGroup> <None Include="Some_Name.snk" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project>
可能的原因及排查方向
- 运行环境依赖缺失/损坏:云流的运行环境可能经历了自动更新、意外重启,导致Azure.Storage.Blobs.dll或者它的依赖组件(比如Azure.Core、Azure.Storage.Common这类基础库)被删除、损坏,或者版本被悄悄替换。插件依赖环境加载这些程序集,一旦文件没了就会触发加载失败。
- 版本冲突导致绑定失败:环境里可能新增了其他应用,或者更新了其他依赖包,其中包含了不同版本的Azure.Storage.Blobs或其依赖(比如Azure.Core版本不兼容),导致程序集绑定重定向失效,CLR找不到匹配版本的文件。
- 部署包不完整:如果最近重新部署过插件,打包时可能漏了Azure.Storage.Blobs的依赖文件。.NET Framework用PackageReference时,要是没正确设置复制本地属性,依赖项可能不会被复制到输出目录,部署后环境里自然缺文件。
- 权限变更:运行插件的云流服务账号突然没了程序集所在目录的读取权限,系统读不到文件也会报这个错。这种情况少见,但环境权限调整可能引发。
- 签名验证失败:你的项目配置了
<SignAssembly>true</SignAssembly>,如果Azure.Storage.Blobs的程序集签名在环境中被篡改,或者运行环境的信任策略变了,CLR会拒绝加载,表面上就显示“找不到文件”。
内容的提问来源于stack exchange,提问作者Johan Pino
相关产品推荐
相关产品推荐

