我已经试过了普通的发布方式和使用IIS的发布方式,但Client端都不能够连接Server端。普通方式显示的信息是找不到发布的服务;而IIS方式是显示"不能正常连接,因为服务器正积极地拒绝它",但是我已经把它设定为Windows集成验证方式和允许匿名访问,并将匿名帐号赋予管理员权限了(ps:我是按照IIS的发布方式将生成为dll的remoting组件放在虚拟目录的bin文件夹里)。不知道是怎么回事?以下是我的config文件设定:
----- server ------
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown
mode="Singleton"
type="Server.QuestionBankService,QuestionBankService"
objecturl="QuestionBankService.rem"
/>
</service>
<channels>
<channel
ref="http"
port="80"
/>
</channels>
</application>
</system.runtime.remoting>
<connectionStrings>
<add name="QBDataBase" connectionString="workstation id=RICKYWORKS;packet size=4096;integrated security=SSPI;data source=RICKYWORKS\\SQLEXPRESS;persist security info=False;initial catalog=QBDataBase" providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>---- client ----
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<client>
<wellknown
type="Server.QuestionBankService,QuestionBankService"
url="http://localhost:80/tryRemoting/QuestionBankService.rem"
/>
</client>
<channels>
<channel
ref="http"
port="0"
/>
</channels>
</application>
</system.runtime.remoting>
</configuration>
----- server ------
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown
mode="Singleton"
type="Server.QuestionBankService,QuestionBankService"
objecturl="QuestionBankService.rem"
/>
</service>
<channels>
<channel
ref="http"
port="80"
/>
</channels>
</application>
</system.runtime.remoting>
<connectionStrings>
<add name="QBDataBase" connectionString="workstation id=RICKYWORKS;packet size=4096;integrated security=SSPI;data source=RICKYWORKS\\SQLEXPRESS;persist security info=False;initial catalog=QBDataBase" providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>---- client ----
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<client>
<wellknown
type="Server.QuestionBankService,QuestionBankService"
url="http://localhost:80/tryRemoting/QuestionBankService.rem"
/>
</client>
<channels>
<channel
ref="http"
port="0"
/>
</channels>
</application>
</system.runtime.remoting>
</configuration>
<wellknown
type="Server.QuestionBankService,QuestionBankService"
url="http://localhost:80/QuestionBankService.rem"
/>
{
//Load config file and do something
}public class RemoteClient
{
private ServerService service; public RemoteClient()
{
//Load config file and initialize object
service = new ServerService();
}
//Do something that use ServerService
}
可能是Remoting存在访问权限的问题??但是MSDN里面没有这方面的说明...
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown
mode="Singleton"
type="Server.QuestionBankService,QuestionBankService"
objecturl="QuestionBankService.rem"
/>
</service>
<channels>
<channel
ref="http"
port="80" ///这里我的写法是没有指定的 去掉看看///
/>
</channels>
</application>
</system.runtime.remoting>
<connectionStrings>
<add name="QBDataBase" connectionString="workstation id=RICKYWORKS;packet size=4096;integrated security=SSPI;data source=RICKYWORKS\\SQLEXPRESS;persist security info=False;initial catalog=QBDataBase" providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>这些配置应该没问题的 就是不知道你的代码怎么写 帮你顶~~~
{
//do something
}public class RemoteClient //这是Client的接口。这里不需要继承MarshalByRefObject了吧?继承后也没用
{
private ServerService service; public RemoteClient()
{
//Load config file and initialize object
service = new ServerService();
}
//Do something that use ServerService
}Server组件的运行方式是启动控制台应用程序,引用QuestionBankService.dll和读取Config file。