In your code, you aren't actually calling the service, instead you are referencing the executable and invoking a method from that assembly (at run time the .NET Framework will use a local assembly to execute the code, not your running service).
To do what you want, you have a number of options.
In .NET 2.0, you would make use of .NET Remoting. You create a remoting interface, which other assemblies can use to invoke methods across executables.
In .NET 3.0, remoting was replaced by WCF. Your service would become a WCF service, which would expose the GetRandomNumber() as part of its data contract. Applications can consume the contract and connect to your service to call the method.
There are a number of good tutorials on the web for both .NET Remoting or its replacement, Windows Communication Foundation.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…