G
Guest
Hi!
I have a config file that looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown mode="SingleCall" type="Interfaces, IMyFirstRemotableObj" objectUri="ControlCenter" />
</service>
<channels>
<channel ref="tcp" port="8086" />
</channels>
</application>
</system.runtime.remoting>
</configuration>
the server looks like this:
-----------------------------------------------
using Interfaces; //added in the referenses
using ClassLib.System; //added in the referenses
RemotingConfiguration.Configure(Environment.CurrentDirectory+"\\server.config");
lblServiceStatus.Text = "Service started";
the client:
-----------------------------------------------
using Interfaces; //added in the referenses
IMyFirstRemotableObj bol;
bol=(IMyFirstRemotableObj)Activator.GetObject(typeof(IMyFirstRemotableObj),@"tcp://192.168.2.24:8086/ControlCenter");
MessageBox.Show(bol.GetOSPlatform());
Interfaces:
-----------------------------------------------
using System;
namespace Interfaces
{
public interface IMyFirstRemotableObj
{
string GetOSPlatform();
}
}
ClassLib.System :
-----------------------------------------------
using System;
using Interfaces;
namespace ClassLib.System
{
[Serializable]
public class MyFirstRemotableObj : MarshalByRefObject, IMyFirstRemotableObj
{
public string GetOSPlatform()
{
return Environment.OSVersion.Version.ToString();
}
}
}
And the error:
-----------------------------------------------
System.IO.FileNotFoundException: File or assembly name IMyFirstRemotableObj, or one of its dependencies, was not found.
File name: "IMyFirstRemotableObj"
Server stack trace:
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Boolean stringized, Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Reflection.Assembly.Load(String assemblyString)
at System.Runtime.Remoting.RemotingConfigInfo.LoadType(String typeName, String assemblyName)
at System.Runtime.Remoting.RemotingConfigInfo.GetServerTypeForUri(String URI)
at System.Runtime.Remoting.RemotingConfigHandler.GetServerTypeForUri(String URI)
at System.Runtime.Remoting.RemotingServices.GetServerTypeForUri(String URI)
at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Interfaces.IMyFirstRemotableObj.GetOSPlatform()
at ControlCenter.ControlCenter.button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
If I use this code in the server:
TcpChannel chan = new TcpChannel(8086);
ChannelServices.RegisterChannel(chan);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyFirstRemotableObj),"ControlCenter",WellKnownObjectMode.SingleCall);
Instead of
RemotingConfiguration.Configure(Environment.CurrentDirectory+"\\server.config");
then it will work fine, what's wrong?
I have a config file that looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown mode="SingleCall" type="Interfaces, IMyFirstRemotableObj" objectUri="ControlCenter" />
</service>
<channels>
<channel ref="tcp" port="8086" />
</channels>
</application>
</system.runtime.remoting>
</configuration>
the server looks like this:
-----------------------------------------------
using Interfaces; //added in the referenses
using ClassLib.System; //added in the referenses
RemotingConfiguration.Configure(Environment.CurrentDirectory+"\\server.config");
lblServiceStatus.Text = "Service started";
the client:
-----------------------------------------------
using Interfaces; //added in the referenses
IMyFirstRemotableObj bol;
bol=(IMyFirstRemotableObj)Activator.GetObject(typeof(IMyFirstRemotableObj),@"tcp://192.168.2.24:8086/ControlCenter");
MessageBox.Show(bol.GetOSPlatform());
Interfaces:
-----------------------------------------------
using System;
namespace Interfaces
{
public interface IMyFirstRemotableObj
{
string GetOSPlatform();
}
}
ClassLib.System :
-----------------------------------------------
using System;
using Interfaces;
namespace ClassLib.System
{
[Serializable]
public class MyFirstRemotableObj : MarshalByRefObject, IMyFirstRemotableObj
{
public string GetOSPlatform()
{
return Environment.OSVersion.Version.ToString();
}
}
}
And the error:
-----------------------------------------------
System.IO.FileNotFoundException: File or assembly name IMyFirstRemotableObj, or one of its dependencies, was not found.
File name: "IMyFirstRemotableObj"
Server stack trace:
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Boolean stringized, Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Reflection.Assembly.Load(String assemblyString)
at System.Runtime.Remoting.RemotingConfigInfo.LoadType(String typeName, String assemblyName)
at System.Runtime.Remoting.RemotingConfigInfo.GetServerTypeForUri(String URI)
at System.Runtime.Remoting.RemotingConfigHandler.GetServerTypeForUri(String URI)
at System.Runtime.Remoting.RemotingServices.GetServerTypeForUri(String URI)
at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Interfaces.IMyFirstRemotableObj.GetOSPlatform()
at ControlCenter.ControlCenter.button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
If I use this code in the server:
TcpChannel chan = new TcpChannel(8086);
ChannelServices.RegisterChannel(chan);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyFirstRemotableObj),"ControlCenter",WellKnownObjectMode.SingleCall);
Instead of
RemotingConfiguration.Configure(Environment.CurrentDirectory+"\\server.config");
then it will work fine, what's wrong?