Create a library project to build the server interface.
Open Visual Studio 2005 IDE. Create a class project as: File
>> New >> Projects.
Choose Visual Basic as in Project Types and "Class
Library" in project templates.
Give the project name as IServer and click OK.
It will create the Iserver project containing a default
class Class1.vb. Rename this class to IServer.vb.
Now implement the following code in Iserver.vb file.
Listing 1: Code for Iserver.vb
Public Interface IServer
Function GetTimeFromServer() As DateTime
End Interface
Build the IServer project.
Create (Add) a library project to build the server
object
In order to have remoting using IIS Server, we will build
remote server object as an assembly. Then we will go for its setup into the IIS
Server.
To add library project for remote server object: In IServer
solution- File >> Add >> New Project.
Choose Visual Basic in the Project Types and "Class
Library" in project templates. Give the project name as Server and click
OK.
It will create the Iserver project containing a default
class Class1.vb. Rename this class to MyServer.vb.
In this we need to import System.EnterpriseServices
namespace and before doing it add a reference of System.EnterpriseServices into
the project.
Project >> Add Reference >> Browse >>
Locate the dll file \IServer\IServer\bin\Debug\IServer.dll (if build in debug
mode) or \IServer\IServer\bin\Release\IServer.dll (if build in release mode)
>> OK
For this example I assume the project is compiled in Debug
mode.
We will implement the functions declared in IServer.dll by
implementing the IServer interface. Change the class name in the code to
clsServer. Add the following code in MyServer.vb for class clsServer to achieve
this.
Listing 2: Code to implement functions of IServer
interface
Public Class clsServer
Inherits MarshalByRefObject
Implements IServer.IServer
'Implement server remote method
Public Overridable Function GetTimeFromServer() As DateTime _
Implements IServer.IServer.GetTimeFromServer
Return Now.ToString()
End Function
End Class
Build the Server project. If the build is successful then we
are ready with the server object and to get it to setup in IIS Server.