gpt4 book ai didi

c# - 从 unity3D 使用 WCF

转载 作者:太空狗 更新时间:2023-10-30 00:53:23 26 4
gpt4 key购买 nike

我在本地主机上的 IIS 中托管了一些 wcf web 服务。我希望能够从 Unity3d 访问它们,但在播放场景时出现以下错误:

InvalidOperationException: Client endpoint configuration 'BasicHTTPEndpoint' was not found in 0 endpoints.
System.ServiceModel.ChannelFactory.ApplyConfiguration (System.String endpointConfig)
System.ServiceModel.ChannelFactory.InitializeEndpoint (System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress)
System.ServiceModel.ChannelFactory`1[IUnityStore]..ctor (System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress)
System.ServiceModel.ClientBase`1[TChannel].Initialize (System.ServiceModel.InstanceContext instance, System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress)
System.ServiceModel.ClientBase`1[TChannel]..ctor (System.ServiceModel.InstanceContext instance, System.String endpointConfigurationName)
System.ServiceModel.ClientBase`1[TChannel]..ctor (System.String endpointConfigurationName)
UnityStoreClient..ctor (System.String endpointConfigurationName)
firstCall.Start () (at Assets/Scripts/firstCall.cs:8)

Web 服务实例化如下:

UnityStoreClient uc = new UnityStoreClient("BasicHTTPEndpoint");
uc.Open(); //i don't know if i need this ?????
UnityStoreLibrary.User[] users = uc.GetAllUsers("1",null);
for (int i=0;i<users.Length;i++)
Debug.Log("username = " + users[i].username);

我的脚本文件夹中有一个配置文件,但我不知道是否应该用它做点什么。我使用 Visual Studio 2010 中的 svcutil 创建了统一类。

最佳答案

using System.ServiceModel;

我的类实现中缺少此语句。

我这样调用网络服务:

UnityStoreClient client = new UnityStoreClient(new BasicHttpBinding(), new EndpointAddress(some_url));

关于c# - 从 unity3D 使用 WCF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16658272/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com