如何添加exe文件作为参考在我的web应用程序我的、应用程序、文件、exe

2023-09-06 08:22:15 作者:半世迷离

我已经创建了它的一些方法,一个exe(以下参考例如EXE)。

I have created an exe with some methods in it (ref example exe below).

using System;  
using System.Collections.Generic;  
using System.Text;  

namespace SampleRef  
{  
  public class Program  
  {  
  static void Main(string[] args)  
    {  
    }  
  }  
  public class Sample  
  {    
   public Sample(int count)  
    {

    }

    public string SampleString(int InputValue)
    {
      //Do something
       return "<the result>";
    }
  }  
}  

我要添加引用此exe到我的web应用程序来调用侧(SampleString)方法的exe文件。是否有可能在.NET和我怎样才能做到这一点?

I want to add reference this exe into my web application to call (SampleString) methods in side the exe. Is it possible in .net and how can I achieve this?

推荐答案

是 - 只需添加它,仿佛它是一个类库。 Visual Studio的自2005年以来一直支持这一点。

Yes - just add it as if it were a class library. Visual Studio has supported this since 2005.

编辑:好的,这听起来像ASP.NET可能不喜欢的.exe程序集:(

Okay, it sounds like ASP.NET may not like .exe assemblies :(

在这种情况下,我建议你从当前的可执行文件中提取code,放入一个类库。您可能会发现更容易改变的全的正常的应用程序到一个DLL - 并且只需添加另一种可执行的项目,什么也不做,但调入DLL启动应用程序。这不应该是终点的你code,但它是一个简单的方法来建立和运行。

In that case I suggest you extract the code from your current executable and put it into a class library. You may find it easier to change the whole of your normal application into a DLL - and just add another executable project which does nothing but call into the DLL to start the "application". That shouldn't be the end-point of your code, but it's an easy way to get up and running.

 
精彩推荐
图片推荐