我有一个WCF主机像这样的东西:获取自定义对象在资源管理器扩展无法正常工作,但在winform
[ServiceContract]
public interface IMountToOs
{
[OperationContract]
char GetMountDriveLetter();
[OperationContract]
MyTestClass MyTest();
}
public class MyTestClass
{
public string A { get; set; }
public string B { get; set; }
}
客户
private IMountToOs _proxy;
public IMountToOs Proxy
{
get
{
if (_proxy == null)
{
NetTcpBinding binding = new NetTcpBinding();
binding.MaxReceivedMessageSize = 2147483647;
binding.OpenTimeout = TimeSpan.FromMilliseconds(50000);
EndpointAddress address = new EndpointAddress("net.tcp://localhost:1234/MountToOsHost");
//_proxy = new MountToOsClient(binding, address);
ChannelFactory<IMountToOs> factory = new ChannelFactory<IMountToOs>(binding);
_proxy = factory.CreateChannel(address);
}
return _proxy;
}
}
虽然我可以访问
MessageBox.Show("Okay - " + Proxy.GetMountDriveLetter());
我不能调用这个方法:
MessageBox.Show("Okay - " + Proxy.MyTest().A);
完整的扩展无法正常工作。但只在扩展中使用它。即使我在扩展的第一行插入Messagebox,它也不会被打中。我不知道为什么。它似乎运行预检查,并找到被拒绝的自定义类的电话或... 如果我使用的WinForm或这样没有问题。
.net 3.5
好奇的是,我有一个断点和主机侧的消息。因此,我认为,该方法不叫
现在更新 我感动在扩展的Load方法的WCF呼叫并获得了异常:
system.missingMethodException而:找不到方法: “Contracts.Interfaces.MyTestClass Contracts.Interfaces.IMountToOs.MyTest()”。
我的winform测试和这个扩展使用相同的接口,以便该方法应该从两者都知道。没有合同或以上已经过时
您是否感到怀疑当你调用Proxy.MyTest()。一个? – user957902 2012-08-14 11:50:38
没有,没有例外,当然我试着用一个try catch和一个文件的异常的File.Write – 2012-08-14 11:54:57
ServiceContract IMountToOs和MyTestClass是不同的程序集?如果是这样,我会检查[Fusion](http://msdn.microsoft.com/en-us/library/e74a18c4(v = vs.100).aspx)日志以查看运行扩展时MyTestClass程序集是否被加载。 – Simon 2012-08-22 00:35:32