System.MissingMethodException 消息=未找到方法:DryIoc.Rules DryIoc.Rules.WithoutFastExpressionCompiler()

System.MissingMethodException Message=Method not found: DryIoc.Rules DryIoc.Rules.WithoutFastExpressionCompiler()

我正在使用 Prism.DryIoc.Extensions(v8.0.62) 和 Prism.DryIoc.Forms(v8.1.97),它们在内部分别使用 DryIoc.dll v4.7.3 和 v4.7.7 作为我的 Xamarin.Forms 项目。

我的项目也有一个 nuget 更新,它在内部使用 DryIoc.dll v5.0.2。

现在,如果我将项目 nuget 更新到最新版本,它会抛出错误。由于版本冲突。

既然是项目相关的nuget,我就得更新一下。但是对 Prism 有依赖性,Prism 还没有发布任何最新版本 DryIoc.dll.

我尝试在 .csproj 文件中添加以下内容

<PackageReference Include="Prism.DryIoc.Extensions" Version="8.0.62">
        <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
        <dependentAssembly>
          <assemblyIdentity name="DryIoc.dll" culture="neutral" />
          <bindingRedirect oldVersion="4.7.3" newVersion="5.0.2" />
        </dependentAssembly>
    </PackageReference>

这解决了编译时错误,但开始抛出 运行 时间错误,如下所示,

System.MissingMethodException Message=Method not found: DryIoc.Rules DryIoc.Rules.WithoutFastExpressionCompiler()

我也尝试创建 app.config 并使用下面的代码片段,

<configuration>
<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="DryIoc" publicKeyToken="dfbf2bd50fcf7768" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-5.0.1.0" newVersion="5.0.2.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>

但这也失败了,并出现与上述相同的错误。

摆脱 Prism 是解决方案之一,但这是一项巨大的努力,因为整个项目都在使用 Prism。

解决此问题的最佳解决方案是什么?请在这方面帮助我。

Prism 的 open source,您可以修改部分以使用 DryIoc 5 并使用那些 dll。

您并不是被迫使用 nuget 包,它们是为了提供帮助。如果他们阻碍,就摆脱他们。

Prism.DryIoc.Forms 在 DryIocContainerExtension 中使用 DryIoc.dll。 Prism 是开源的,因此,我克隆了 repo,将 DryIoc.dll 更新为 5.0.2 并构建了它,发现 WithoutFastExpressionCompiler 已在最新的 DryIoc.dll 中删除。因此删除了该方法并创建了一个 dll 并开始在我的项目中使用。它开始工作了。