环境:
Windows Server 2003 SP2
Microsoft Visual Studio 2005
Castle.DynamicProxy 1.1.5服务端代码:
ProxyGenerator generator = new ProxyGenerator();
object proxy = generator.CreateClassProxy(typeof(ServiceClass),new Interceptor());
IDictionary prop = new Hashtable();
prop["port"] =20002;
IChannel tcpChannel = new TcpChannel(prop, null, null);
ChannelServices.RegisterChannel(tcpChannel, false);
RemotingConfiguration.RegisterWellKnownServiceType(proxy.GetType(), "test", WellKnownObjectMode.Singleton);客户端代码:
object obj = RemotingServices.Connect(typeof(ServiceClass), "tcp://192.168.1.100:20002/test");
ServiceClass sc = obj as ServiceClass;
try
{
int b = sc.Sum(1, 2);} //这个地方抛错,异常见下面
catch (Exception ex)
{ }异常:
未能加载文件或程序集“DynamicAssemblyProxyGen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null”或它的某一个依赖项。系统找不到指定的文件。注:
我已经把所有相关的DLL复制到“客户端”“服务端”目录下了,仍然找不到程序集!
Windows Server 2003 SP2
Microsoft Visual Studio 2005
Castle.DynamicProxy 1.1.5服务端代码:
ProxyGenerator generator = new ProxyGenerator();
object proxy = generator.CreateClassProxy(typeof(ServiceClass),new Interceptor());
IDictionary prop = new Hashtable();
prop["port"] =20002;
IChannel tcpChannel = new TcpChannel(prop, null, null);
ChannelServices.RegisterChannel(tcpChannel, false);
RemotingConfiguration.RegisterWellKnownServiceType(proxy.GetType(), "test", WellKnownObjectMode.Singleton);客户端代码:
object obj = RemotingServices.Connect(typeof(ServiceClass), "tcp://192.168.1.100:20002/test");
ServiceClass sc = obj as ServiceClass;
try
{
int b = sc.Sum(1, 2);} //这个地方抛错,异常见下面
catch (Exception ex)
{ }异常:
未能加载文件或程序集“DynamicAssemblyProxyGen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null”或它的某一个依赖项。系统找不到指定的文件。注:
我已经把所有相关的DLL复制到“客户端”“服务端”目录下了,仍然找不到程序集!
谢谢,您说的不是很清楚。服务端启动正常,客户端也能正常获得Remoting服务,但是调用Remoting方法的时候出错。
<assemblies>
<add assembly="Microsoft.Office.Interop.Word, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"/>
<add assembly="nunit.framework, Version=2.2.10.0, Culture=neutral, PublicKeyToken=96D09A1EB7F44A77"/>
</assemblies>
</compilation>把你所引用的在webconfig里面引用进来。程序集没有找到。肯定是没有引用进来。或者。所引用用到的组件没有安装。
[NameSpace.ClassName], [AssemblyName], [Version], [Culture], [PublicKeyToken]你这个DynamicAssemblyProxyGen到底是类名还是Assembly的名字?
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServiceClass), "test", WellKnownObjectMode.Singleton);