Dear Sir,
I know its very common problem which has been asked by many people but i did not get any of the persons way of immplementing Remoting as i did so please go through with my steps of my project and provide me solution...
The steps which i used in my program ....
Server Side Code...my app.config code
<?
xml version="1.0" encoding="utf-8" ?>
<
configuration>
<
connectionStrings>
<
add name="VitalDataBaseCon" connectionString ="initial Catalog=pubs ;uid=sa;pwd=success; server=VITAL-17\\VITAL17;integrated security=true"></add>
</
connectionStrings>
<
appSettings>
<
add key ="serverIp" value="192.168.1.17"/>
<
add key ="ServerPort" value="8080"/>
</
appSettings>
<
system.runtime.remoting>
<
customError Mode="on"/>
<
application>
<
service>
<
wellknown mode="SingleCall" type="Vital.DotNet.Server.LogIn,Server" objectUri="LogIn" />
</
service>
<
channels>
<
channel ref="tcp" secure="true" port="8080" impersonate="true" protectionLevel="EncryptAndSign"/>
</
channels>
</
application>
</
system.runtime.remoting>
</
configuration>
Server.cs
using
System;
using
System.Collections.Generic;
using
System.Text;
using
System.Data;
using
System.Data.SqlClient;
using
System.Configuration;
using
System.Runtime.Remoting.Lifetime;
using
System.Runtime.Remoting.Channels;
using
System.Runtime.Remoting.Channels.Tcp;
namespace
Vital.DotNet.Server
{
class LogIn:MarshalByRefObject,Vital.DotNet.Server.IvitalServerInterfaces
{
SqlDataAdapter adap;
SqlCommand cmd;
SqlConnection con;
public DataSet retriveData(string authorFirstName,string authorLastName,out bool isSuccess)
{
con =
new SqlConnection("initial Catalog=pubs ;uid=sa;pwd=success; server=VITAL-17\\VITAL17;integrated security=true");
con.Open();
SqlCommand cmd = new SqlCommand("Demoinput", con);
cmd.CommandType=
CommandType.StoredProcedure;
cmd.Parameters.Add(
new SqlParameter("@au_fname",authorFirstName));
cmd.Parameters.Add(
new SqlParameter("@au_lname",authorLastName));
DataSet ds = new DataSet();
SqlDataAdapter adap = new SqlDataAdapter(cmd);
adap.Fill(ds);
if (ds.Tables[0].Rows.Count == 0)
{
isSuccess =
false;
}
else
{
isSuccess =
true;
}
return ds;
}
static void Main(string[] args)
{
Console.ReadLine();
}
}
}
My procedure in pubs data base
create procedure [dbo].[Demoinput]( @au_lname varchar(50),@au_fname varchar(50))
as
begin
select * from authors
where au_lname=@au_lname
end
Interface on server side which has been added on client side as a DLL.
namespace
Vital.DotNet.Server
{
public interface IvitalServerInterfaces
{
DataSet retriveData(string authorFirstName, string authorLastName, out bool isSuccess);
}
}
CLIENT Side Code
client side app.config file
<?
xml version="1.0" encoding="utf-8" ?>
<
configuration>
<
appSettings>
<
add key ="serverIp" value="192.168.1.7"/>
<
add key ="ServerPort" value="9002"/>
</
appSettings>
<
system.runtime.remoting>
<
application>
<
channels>
<
channel ref="tcp" secure="true" tokenImpersonationLevel="Identification" username="" password=""/>
</
channels>
</
application>
</
system.runtime.remoting>
</
configuration>
client.cs
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Text;
using
System.Windows.Forms;
using
Vital.DotNet.Server;
using
System.Configuration;
using
System.Runtime.Remoting.Lifetime;
using
System.Runtime.Remoting.Channels;
using
System.Runtime.Remoting.Channels.Tcp;
namespace
Vital.DotNet.client
{
public partial class Form1 : Form
{
Vital.DotNet.Server.
IvitalServerInterfaces ObjServerSide = null;
bool isSuccess = false;
public Form1()
{
InitializeComponent();
}
private void btnShow_Click(object sender, EventArgs e)
{
try
{
ObjServerSide = (
IvitalServerInterfaces)Activator.GetObject(typeof(IvitalServerInterfaces), @"tcp://192.168.1.17" + ":8080" + "/pop");
ObjServerSide.retriveData(txtAuthorFirstName.Text, txtAuthorLastName.Text,
out isSuccess);
}
catch (System.Runtime.Remoting.RemotingException ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
please help me out from this problem ,i checked this codeon remote computer(On LAN) as well as same computer but it doesnot work....
Thanks and regards
AMRITA VISHNOI