在Web API项目中使用DLL [英] Using a DLL in the Web API Project

查看:57
本文介绍了在Web API项目中使用DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用与服务器通信的dll,而在C#的控制台应用程序中使用DLL时,效果很好.但是,当我在Web API项目中使用DLL时,它既不会记录任何日志,也不会返回正确的响应.

I want to use a dll which communicates with a server, while using the DLL in the Console Application in C# it worked fine. But when I am using the DLLs in the Web API project it is not making any logs and also not returning correct response.

DLL使用一个.config文件,该文件应位于与DLL相同的位置.在这两种情况下,我都将配置文件粘贴到bin文件夹中,但仍然得到了不同的结果.

The DLL uses a .config file which should be present in the same location as that of the DLL. I have pasted the config file in the bin folder in both the cases but still got the different results.

这可能是什么原因.

推荐答案

IIS 使用

IIS uses Shadow Copying, i.e. it copies all DLLs from bin into temporary folder. Your configuration file is probably not copied during this process, causing your communication DLL to fail in finding it's .config.

您可以在应用程序启动期间将 .config 文件复制到目标临时bin文件夹,也可以副作用).

You could either copy .config file to target temporary bin folder during application startup, or disable shadow copying in web.config (with all it's side effects).

这篇关于在Web API项目中使用DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆