How is it possible to send the whole content of an existing notebook to Mathematica for evaluation by using NetLink/C#?
To evaluate a notebook from .NET, a batch file and a package file can be used. This example opens and evaluates a notebook called "run.nb" in the front end. Ref:- https://stackoverflow.com/q/7626491/879601
i.e. batch file:-
@echo off setlocal PATH = C:\Program Files\Wolfram Research\Mathematica\8.0\;%PATH% start MathKernel -noprompt -initfile "C:\Temp\test.m" endlocal
and package file,
Needs["JLink`"]; $FrontEndLaunchCommand="Mathematica.exe"; UseFrontEnd[ nb = NotebookOpen["C:\\Temp\\run.nb"]; SelectionMove[nb, All, Notebook]; SelectionEvaluate[nb]; ]; Pause; CloseFrontEnd;
The batch file and package file can be created on the fly and run from .NET, (or perhaps you could execute the start command directly and dispense with the batch file).
Alternatively, you could run the main notebook (as a package) in Mathematica script mode. The above answer uses the front end in order to save output cell information.
Your question mentions evaluating an existing notebook, but if you also need to create the notebook in .NET this post may be of use:- https://stackoverflow.com/a/7321479/879601