i have this code for doing a remoting i m giving you all the necessary file codes
this application working fine when im using the client as a windows form but when im triyng to use it with a web form it gives an exception
at
bool st=login.CheckUn(txtun.Text);
its giving an null refereance exception
please can any one tell me what im doing wrong here
here's the code for client
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using LoginComponent;
namespace NewTechBooks
{
/// <summary>
/// Summary description for Home_beforelogin.
/// </summary>
public class Home_beforelogin : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox txtun;
protected System.Web.UI.WebControls.TextBox txtpwd;
protected System.Web.UI.WebControls.Button btnsign;
protected System.Web.UI.WebControls.CustomValidator cvun;
protected System.Web.UI.WebControls.CustomValidator cvpwd;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label lbls;
ILogin login=null;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
try
{
ChannelServices.RegisterChannel(new TcpChannel());
login=(ILogin)Activator.GetObject(typeof(LoginComponent.ILogin),"tcp://localhost:6392/theLogin");
}
catch(Exception ex)
{
lbls.Text=ex.ToString();
}
}
private void btnsign_Click(object sender, System.EventArgs e)
{
bool st=login.CheckUn(txtun.Text);
}
}}}
here is the server code
+++++++++++++++++++++++++++++++++++++++++++++++++
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
namespace NTBS_Server
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Server
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
try
{
ChannelServices.RegisterChannel(new TcpChannel(6392));
RemotingConfiguration.RegisterWellKnownServiceType(typeof(Login),"theLogin",WellKnownObjectMode.SingleCall);
}
catch(Exception ex)
{
Console.WriteLine(ex);
}
System.Console.WriteLine("Press Enter to exit....");
System.Console.ReadLine();
}
}
}
here is the code for login class
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
using System;
using System.Data;
using System.Data.SqlClient;
using LoginComponent;
namespace NTBS_Server
{
/// <summary>
/// Summary description for Login.
/// </summary>
public class Login : MarshalByRefObject, ILogin
{
DBConnector dbc = null;
public Login()
{
dbc= new DBConnector();
dbc.OpensCon();
}
public bool CheckUn(string un)
{
SqlDataReader sdr=dbc.ExecuteSQlUsingReader("select cFirst_Name from Customer_Details where cUser_Name='"+un+"'");
if(sdr.HasRows)
{
System.Console.WriteLine("1");
return true;
}
else
{
System.Console.WriteLine("1");
return false;
}
}
/*public bool CheckPwd(string pwd)
{
return true;
}
public string getValue(string un, string pwd)
{
return pwd;
}*/
}
}
here is the code for the remote inter face code
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
using System;
namespace LoginComponent
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public interface ILogin
{
bool CheckUn(string un);
}
}
like i said erlier this code is working fine with the windows form but i wan to know how to use thi in a webform aspx file above clien is my aspx file
thank you in advance