I know I can spawn new process using compiled exe file.
Suppose I have a class with a method in my app which I want to be run in the separate process.
Can I compile this method into separate assembly in run-time and spawn process running this newly created file?
Sure… look at
CSharpCodeProviderthat can read and compile code to e.g. an .exe filehttp://msdn.microsoft.com/en-us/library/microsoft.csharp.csharpcodeprovider.aspx