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>";
}
}
}
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?
Yes – just add it as if it were a class library. Visual Studio has supported this since 2005.
EDIT: Okay, it sounds like ASP.NET may not like .exe assemblies 🙁
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.