在ChannelFactory<>中没有typeloadeexception.在.net / windows上也不例外
本文关键字:net windows 也不例外 typeloadeexception ChannelFactory | 更新日期: 2023-09-27 18:13:54
我正在创建一个网络。基于tcp的WCF服务来控制我们的一个后端应用程序。在Windows机器上的开发和测试过程中,一切都按照预期进行。然而,当我试图在相同的Windows盒子(Mono 2.10.6)或Debian Squeeze (Mono 2.10.5)上使用Mono运行相同的应用程序时,我突然在ChannelFactory
中得到一个TypeLoadException
。
最后就是这个调用失败了:
controlHost = ChannelFactory<IControlServiceContract>.CreateChannel(
new NetTcpBinding(SecurityMode.None),
new EndpointAddress(endpointAddress)
);
对于IControlServiceContract
在另一个汇编中的定义:
[ServiceContract]
public interface IControlServiceContract
{
[OperationContract(IsOneWay = true)]
void Ping ();
[OperationContract(IsOneWay = true)]
void Shutdown ();
[OperationContract]
int GetCommandCount ();
}
直接启动时运行良好(即使用。net)。
当使用mono --debug --runtime=v4.0
执行时,虽然它崩溃了,但有这个超级甜蜜的堆栈跟踪:
! Ein Fehler ist beim Erzeugen des Kanals auf net.tcp://localhost:34684/watchdog/watchdog.ctrl/ aufgetreten
A type load exception has occurred.
at System.Linq.Enumerable.Union[Object] (IEnumerable`1 first, IEnumerable`1 second, IEqualityComparer`1 comparer) [0x00014] in C:'cygwin'tmp'monobuild'build'BUILD'mono-2.10.6'mcs'class'System.Core'System.Linq'Enumerable.cs:2948
at System.Linq.Enumerable.Union[Object] (IEnumerable`1 first, IEnumerable`1 second) [0x00007] in C:'cygwin'tmp'monobuild'build'BUILD'mono-2.10.6'mcs'class'System.Core'System.Linq'Enumerable.cs:2938
at System.ServiceModel.Description.ContractDescriptionGenerator.GetOrCreateOperation (System.ServiceModel.Description.ContractDescription cd, System.Reflection.MethodInfo mi, System.Reflection.MethodInfo serviceMethod, System.ServiceModel.OperationContractAttribute oca, System.Type asyncReturnType, Boolean isCallback, System.Type givenServiceType) [0x001f2] in C:'cygwin'tmp'monobuild'build'BUILD'mono-2.10.6'mcs'class'System.ServiceModel'System.ServiceModel.Description'ContractDescriptionGenerator.cs:314
at System.ServiceModel.Description.ContractDescriptionGenerator.FillOperationsForInterface (System.ServiceModel.Description.ContractDescription cd, System.Type exactContractType, System.Type givenServiceType, Boolean isCallback) [0x00131] in C:'cygwin'tmp'monobuild'build'BUILD'mono-2.10.6'mcs'class'System.ServiceModel'System.ServiceModel.Description'ContractDescriptionGenerator.cs:240
at System.ServiceModel.Description.ContractDescriptionGenerator.GetContractInternal (System.Type givenContractType, System.Type givenServiceType, System.TypeserviceTypeForCallback) [0x00296] in C:'cygwin'tmp'monobuild'build'BUILD'mono-2.10.6'mcs'class'System.ServiceModel'System.ServiceModel.Description'ContractDescriptionGenerator.cs:197
at System.ServiceModel.Description.ContractDescriptionGenerator.GetContract (System.Type givenContractType, System.Type givenServiceType, System.Type serviceTypeForCallback) [0x00000] in C:'cygwin'tmp'monobuild'build'BUILD'mono-2.10.6'mcs'class'System.ServiceModel'System.ServiceModel.Description'ContractDescriptionGenerator.cs:136
at System.ServiceModel.Description.ContractDescriptionGenerator.GetContract (System.Type givenContractType, System.Type givenServiceType) [0x00000] in C:'cygwin'tmp'monobuild'build'BUILD'mono-2.10.6'mcs'class'System.ServiceModel'System.ServiceModel.Description'ContractDescriptionGenerator.cs:131
at System.ServiceModel.Description.ContractDescriptionGenerator.GetContract (System.Type contractType) [0x00000] in C:'cygwin'tmp'monobuild'build'BUILD'mono-2.10.6'mcs'class'System.ServiceModel'System.ServiceModel.Description'ContractDescriptionGenerator.cs:101
at System.ServiceModel.Description.ContractDescription.GetContract (System.Type contractType) [0x00017] in C:'cygwin'tmp'monobuild'build'BUILD'mono-2.10.6'mcs'class'System.ServiceModel'System.ServiceModel.Description'ContractDescription.cs:66
at System.ServiceModel.ChannelFactory`1[com.derixx.dll.controlservicehost.ServiceBase.IControlServiceContract].CreateDescription () [0x00000] in C:'cygwin'tmp'monobuild'build'BUILD'mono-2.10.6'mcs'class'System.ServiceModel'System.ServiceModel'ChannelFactory_1.cs:185
at System.ServiceModel.ChannelFactory`1[com.derixx.dll.controlservicehost.ServiceBase.IControlServiceContract]..ctor (System.Type type) [0x00033] in C:'cygwin'tmp'monobuild'build'BUILD'mono-2.10.6'mcs'class'System.ServiceModel'System.ServiceModel'ChannelFactory_1.cs:56
at System.ServiceModel.ChannelFactory`1[com.derixx.dll.controlservicehost.ServiceBase.IControlServiceContract]..ctor (System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) [0x00000] in <filename unknown>:0
at System.ServiceModel.ChannelFactory`1[com.derixx.dll.controlservicehost.ServiceBase.IControlServiceContract].CreateChannel (System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress address) [0x00000] in C:'cygwin'tmp'monobuild'build'BUILD'mono-2.10.6'mcs'class'System.ServiceModel'System.ServiceModel'ChannelFactory_1.cs:130
at applicationframework.ControlApplicationBase.ConnectionCreate (IControlServiceContract& controlHost, System.String endpointHost, Int32 endpointPort, System.String endpointPath) [0x00000] in <filename unknown>:0
在这个项目中使用的所有程序集都是我们自己针对Framework 4.0,核心程序集和log4net 1.2.10/2.0.50727的程序集。
有没有人知道这可能是什么,我应该从哪里开始挖掘?
好吧,如果它工作在。net而不是Mono,这肯定是一个bug。
首先要提交到http://bugzilla.xamarin.com/
然后可以在irc://irc.gnome.org/mono中闲逛,并询问WCF的维护者Atsushi Enomoto (nick "eno"),看看他是怎么想的。