周建松:C# remoting 配置问题

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/20 03:55:47
我想采用是remoting 的局域网远程组件方案
也就是采用tcp 通道调用远程组件
我在服务器中建立了一个组件BaiceInfor.cs
又建立了一个普通windows程序
BaiceInfor.cs 代码如下

using System;

namespace FoodService
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
public class BaiceInfor

{
public BaiceInfor()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public string test()
{
return "你好";
}
}
}

windows 窗体代码如下:
using System.Runtime.Remoting;

namespace FoodServiceHost
{
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
server = new BaiceInfor();
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(144, 72);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(88, 32);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(144, 136);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(88, 16);
this.label1.TabIndex = 1;
this.label1.Text = "label1";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(408, 277);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
RemotingConfiguration.Configure("FoodServiceHost.config");
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{

}

private void button1_Click(object sender, System.EventArgs e)
{
string a =server.test();
label1.Text =a;
}
}
}
----------------------
就早载如配置文件处出错提示
:找不到所给的文件 .cfig文件
RemotingConfiguration.Configure("FoodServiceHost.config");
后把文件名字加了路径也不行
请高手指教
我该怎么办啊!
该怎么配置啊