dpn517111 2013-07-12 14:12
浏览 82
已采纳

Web和C#.dll之间的交互

I have to call a method of a complex .dll C# library when I get a "request". Since I don't want to program the network part (socket, protocol, etc.), I'm thinking of using an existing Web server (IIS or Apache) to handle this part (and use HTTP as protocol).

  1. Is it possible to load the .dll in memory and call a method of it from a web server? How to do it?
  2. If yes, is it better to use IIS on Windows, Apache or Windows, or Apache on Linux?
  3. Is it mandatory to call this method of the C# .dll using C#/ASP? Or can it be with PHP?

It has to be very scalable, and the .dll library uses the .NET Framework.

Of course I'm thinking of exec function in PHP, but this would start a C# program again and again for each single request, which is not very good. I would like to load the C# .dll once in memory, and have it running on the web server directly if possible, so that only "calls" to a method happen when I get a specific HTTP request.

My question has similarities to this one, however I don't believe our problems are the same.

  • 写回答

1条回答 默认 最新

  • dongyou6795 2013-07-12 14:40
    关注

    Is it possible to load the .dll in memory and call a method of it from a web server? How to do it?

    Yes, for example by programming a service layer around it using WCF or the ASP.NET Web API. Given the quirky (to say the least) interoperation of SOAP services and clients, I'd go with the latter.

    You can then call your SOAP/REST/giveitaname service through PHP's cURL or any other applicable method, and your C# service will then call the code in the DLL (this part you'll have to build).

    You can host both types of project easily in IIS, making it accessible through HTTP.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求码,CNN+LSTM实现单通道脑电信号EEG的睡眠分期评估
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路