gpt4 book ai didi

c# - DNN 7 Web API 模块;无法加载文件或程序集

转载 作者:太空宇宙 更新时间:2023-11-03 12:40:31 28 4
gpt4 key购买 nike

背景

我正在为现有的 DNN 7 网站构建移动应用程序;由大约一年前离开的其他人制作。我之前设置了一个 WebApi 模块来处理身份验证。然后我有了建立一个类库来保存我的 DTO 对象的想法;因为我必须修改几个现有模块以公开 Web 方法,并且它们必须与我的应用程序交互。所以我创建了一个类库,放入两个类并编译。添加了对我的应用程序和 Web 模块的 dll 引用,并且在引用我的对象时构建它们没有问题。但是,当我从我的应用程序或 Postman chrome 扩展程序向我的模块发送 Web 请求时,我得到:

"Could not load file or assembly 'Elf.Web.Models, Version=1.0.6081.13955,   Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.",

我的应用在创建和使用对象时似乎没有问题,只是在使用 web 模块时。

我尝试/检查的内容

属性 我确保我的类库和我的网络模块都针对同一个框架; .NET Framework 4.5

Reference Property Copy Local 为 True 且符合 Other Question我尝试手动编辑我的 .csproj 文件以在我的引用下将属性 Private 添加到 True。我什至尝试向我的程序集添加绑定(bind)重定向。

手动 我还尝试打开我的模块安装 zip 将类库 dll 扔到 bin 文件夹中,重新压缩,然后安装到 dnn 站点。问题仍然存在。

如果其他人知道什么可能是问题,我们将不胜感激。

最佳答案

将库 dll 放入安装程序 zip 文件的 bin 文件夹中不会在安装过程中自动将库 dll 文件放入 DotNetNuke 安装的 bin 文件夹中。

将其添加到 <components> 下的安装程序 .dnn 文件中节点。

<component type="Assembly">
<assemblies>
<assembly>
<name>myLibrary.dll</name>
<path>bin</path>
</assembly>
</assemblies>
</component>

如果您希望文件自动添加到安装程序 zip 中,您必须在 ModulePackage.targets 中进行引用文件。

<Copy SourceFiles="$(MSBuildDnnBinPath)\myLibrary.dll" DestinationFolder="$(MSBuildProjectDirectory)\Package\bin"/>

关于c# - DNN 7 Web API 模块;无法加载文件或程序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39148411/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com