Hololens应用尝试与WCF Web服务进行HTTP连接时缺少方法异常?

问题描述 投票:0回答:1

我们正在尝试使用System.ServiceModel.dll在WCF Web服务上执行调用。我们的应用程序生成并部署OK,但在运行时会生成以下错误。.

System.MissingMethodException: The method 'System.Void System.ServiceModel.BasicHttpBinding::.ctor()' has no implementation.

该应用程序是使用位于Assets / Plugins / WSA / x86 /中的System.ServiceModel.dll构建的,并配置为在Hololens平台(WSAPlayer)上使用,如下所示。如何解决缺少的方法异常?

我们尝试使用System.ServiceModel.dll的不同变体,它们位于“ C:\ Program Files(x86)\ Reference Assemblies \ Microsoft \ Framework.NETFramework”和“ C:\ Program Files \ Unity \ Editor \ Data \”中,没运气。不确定此错误是如何开始的,因为我们的应用程序过去可以正常工作。

unitydllconfiguration

客户电话代码

#if !UNITY_EDITOR
public static Service1Client client;
#endif

void Awake()
{
#if !UNITY_EDITOR
    client = new Service1Client(new BasicHttpBinding(),
        new EndpointAddress("http://myServer/myService/myService.Service1.svc"));

    ((BasicHttpBinding)client.Endpoint.Binding).MaxBufferSize = 200000000;
    ((BasicHttpBinding)client.Endpoint.Binding).SendTimeout = System.TimeSpan.FromMinutes(3);
    ((BasicHttpBinding)client.Endpoint.Binding).MaxReceivedMessageSize = 200000000;
#endif
}

MyServiceClient.cs(从命令行使用Svcutil.exe生成)

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

#if !UNITY_EDITOR

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName = "IService1")]
public interface IService1
{

    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IService1/getFolderNames", ReplyAction = "http://tempuri.org/IService1/getFolderNamesResponse")]
    string[] getFolderNames();

    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IService1/getFileNames", ReplyAction = "http://tempuri.org/IService1/getFileNamesResponse")]
    string[] getFileNames(string fldrPath);

    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IService1/getFileData", ReplyAction = "http://tempuri.org/IService1/getFileDataResponse")]
    byte[] getFileData(string filePath);
}

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public interface IService1Channel : IService1, System.ServiceModel.IClientChannel
{
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class Service1Client : System.ServiceModel.ClientBase<IService1>, IService1
{

    public Service1Client()
    {
    }

    public Service1Client(string endpointConfigurationName) :
            base(endpointConfigurationName)
    {
    }

    public Service1Client(string endpointConfigurationName, string remoteAddress) :
            base(endpointConfigurationName, remoteAddress)
    {
    }

    public Service1Client(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
            base(endpointConfigurationName, remoteAddress)
    {
    }

    public Service1Client(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
            base(binding, remoteAddress)
    {
    }

    public string[] getFolderNames()
    {
        return base.Channel.getFolderNames();
    }

    public string[] getFileNames(string fldrPath)
    {
        return base.Channel.getFileNames(fldrPath);
    }

    public byte[] getFileData(string filePath)
    {
        return base.Channel.getFileData(filePath);
    }
}

#endif

该服务运行正常,如下所示

servicebrowserscreenshot

c# wcf unity3d hololens service-model
1个回答
0
投票

关于使用哪个问题,位于Assets \ Plugins \ WSA \ x86 \ System.ServiceModel.dll的插件是正确的。

部署到设备是否显示相同的行为?另外,可以共享正在生成此错误的特定Unity版本吗?

我使用上面的代码做了一个测试UWP应用程序,以部署到HoloLens设备上,并且无法重现报告。因此,需要有关Unity版本的更多详细信息以提供帮助。

谢谢,内森-MSFT

© www.soinside.com 2019 - 2024. All rights reserved.