【发布时间】:2012-09-11 19:26:10
【问题描述】:
我有一个在控制台应用程序中工作但在窗口服务中不工作的 .Net Remoting。它返回我空类型。我不知道这里有什么问题
static void TicketServer()
{
System.Diagnostics.Debugger.Break();
//Console.WriteLine("Ticket Server started...");
TcpChannel tcpChannel = new TcpChannel(9988);
ChannelServices.RegisterChannel(tcpChannel, true);
Type commonInterfaceType = Type.GetType("WindowsService.MovieTicket");
RemotingConfiguration.RegisterWellKnownServiceType(commonInterfaceType,
"MovieTicketBooking", WellKnownObjectMode.SingleCall);
}
我在 Windows 服务中得到“commonInterfaceType”空值,而在控制台应用程序中工作正常。当我将应用程序从控制台转移到 Windows 服务时,我还更改了命名空间
我找到了问题,但需要知道为什么会在 Windows 服务中发生这种情况,例如图像中突出显示的行在控制台应用程序中工作正常,但在 Windows 服务中返回 null。
http://desmond.imageshack.us/Himg339/scaled.php?server=339&filename=testimg.png&res=landing
如果我没记错的话,我认为这是微软的错误...... 谢谢
【问题讨论】:
-
服务在哪个账户下运行?它可以访问网络吗?
-
不要使用remoting它不能很好地工作并且被MS放弃了。使用 WCF...
-
如果 commonInterfaceType 为 null,这意味着加载程序无法加载类型“WindowsService.MovieTicket”。您可以查看 Fusion Log (fuslogvw.exe) 找出原因。类型在什么组件中?如果它与此代码所在的程序集不同,则需要指定程序集限定类型名称。类型名称和命名空间拼写是否正确?
-
自动,使用LocalSystem Account,还是需要网络访问的,这是一个简单的应用。 Natza Mitzi,由于某些原因,我需要在这里使用远程处理... Chris Dickson,我在其中使用了程序集的确切名称,我认为没有输入错误。
-
@taha ahmed:
Type.GetType("WindowsService.MovieTicket");- 这里没有程序集名称,只有命名空间限定的类型名称。
标签: c# asp.net .net windows-services remoting