Hello!
I'm developing an aspnet remoting (using C#) for the first time and facing some unexpected issues.
There are four projects in my solution (VS2005, framework 2.0)
A business layer (classlibrary)
An interface component - to interact with the business layer (classlibrary)
A WebApplication - where I've placed my aspx that interacts with the interface component.
A console application (to open the remoting channel).
Here is what I'm doing, respectively:
---
using InterfaceRemoting;
namespace Negocio
{
public class Client : MarshalByRefObject, InterfaceRemoting.IClient
{
public Client()
{
}
public DataTable getData()
{
SqlConnection conn = new SqlConnection();
SqlCommand cmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();
conn.ConnectionString = "The ConnectionString";
cmd.Connection = conn;
cmd.CommandText = "The CommandText";
da.SelectCommand = cmd;
da.Fill(dt);
conn.Dispose();
cmd.Dispose();
da.Dispose();
return dt;
}
}
}
------------------------------------------------------
using System;
using System.Data;
namespace InterfaceRemoting
{
public interface ICliente
{
DataTable getData();
}
}
--------------------------------------------------------
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels.Http;
using DataDynamics.ActiveReports;
using DataDynamics.ActiveReports.Web;
using DataDynamics.ActiveReports.Document;
using InterfaceRemoting;
using Reports;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
IClient cli = (IClient)Activator.GetObject(typeof(IClient), "http://localhost/RMTReport/Default.aspx");
RptTest reportDesign = new RptTest();
reportDesign.DataSource = cli.getData();
ReportViewer.Report = reportDesign;
}
}
------------------------------------------------------------------------------------------------------------------------------------------------------------
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
using Negocio;
namespace Server
{
class Program
{
[STAThread]
static void Main(string[] args)
{
ChannelServices.RegisterChannel(new HttpServerChannel(),true);
WellKnownServiceTypeEntry wkste = new WellKnownServiceTypeEntry(typeof(Client), "Negocio", WellKnownObjectMode.Singleton);
RemotingConfiguration.RegisterWellKnownServiceType(wkste);
Console.WriteLine("Criou Remoting");
Console.ReadLine();
}
}
}
Well, my doubts are highlighted in red...I mean what is the connection between the ObjectURI parameter of the wkste object and the URL parameter of the Activator.GetObject method?
Could it be the source of the (403) forbidden exception message I got when the reportDesign.DataSource = cli.getData() statement is performed?
Is there any IIS configuration that can be causing that excepting too?
I've also changed some properties in the "Set Startup Projects" (seted the console and web application to start together)...
With this scenario in mind, what do you think I'm doing wrong to cause the exception?