I am trying to interface R with C# web application.I tried many solutions being provided but couldn\'t get it through. Error I am getting is: Exception from HRESULT: 0x80040
I believe R.NET is a much better way to access R functionality from C#. It all runs in-process and so doesn't require an external R process to be running.
If you install the NuGet package, you will get version 1.5. This incorporates some memory management fixes I made that address most of the crashes people have reported. As Dieter points out, we use R.NET extensively via the F# RProvider, and it is extremely stable with the latest version. The RProvider also comes with a wrapper generator that generates wrapper functions for R functions which can be used from C#. So for example you could call the plot function from C# as R.plot(...params...). And you get Intellisense.
I have used the COM method to interface to c# some years ago, but I gave up because on each version change there were problems similar to that you mentioned. In addition, the licensing scheme of R(D)COM is a bit obscure to me, and the .NET/COM/R tour has too many corners.
My current choice is Rserve, which is well maintained and has never let me down. I had written my own test bed for c#, but I consider it obsolete because RserveCLI is more complete.
R.NET in theory is a better concept, but for strange reasons it is considered "stable" by the author, which is highly euphemistic because of the many bugs mainly in memory management. Too bad it never took off.