mono - 在 MonoDevelop/MonoTouch : how to use the app. 配置文件中使用 WCF?

标签 mono xamarin.ios monodevelop

我在我的 MT 项目中添加了对 WCF 服务的 Web 引用(此处使用 MonoDevelop 2.4.2)。 我正在尝试回收 Visual Studio 使用的 app.config 文件。我将它复制到我的 MT 的根目录中,并在 MonoDevelop 中指定“复制到输出目录”。仍然不起作用。 在 MonoDevelop 中使用 app.config 的正确方法是什么?

雷内

最佳答案

不幸的是,您不能在 Monotouch 中使用 app.config 文件。您必须自己在代码中创建所有绑定(bind)。在我们的一个项目中,这是我们所做的:

public static ServiceClient GetClient()
{
    BasicHttpBinding binding = new BasicHttpBinding();
    binding.OpenTimeout = new TimeSpan(0,0,10);
    binding.CloseTimeout = new TimeSpan(0,0,10);
    binding.SendTimeout = new TimeSpan(0,0,10);
    binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
    binding.BypassProxyOnLocal = false;
    binding.AllowCookies = false;


    // snip - we set all the properties found in the serverside config file in code here

    EndPointAddress endpointAddress = new EndpointAddress("https://www.domain.com/ServiceClient.svc");
    ServiceClient client = new ServiceClient(binding, endpointAddress);
    return client;
}

您需要遍历并设置在服务器的 app.config 文件中找到的每个属性,确保值完全匹配,否则这将不起作用。 (如果我误解了您的问题,那么我深表歉意!)。

关于mono - 在 MonoDevelop/MonoTouch : how to use the app. 配置文件中使用 WCF?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6665941/

相关文章:

iphone - iOS6 从后台返回后应用程序崩溃

c# - 用于 .NET 的强大且友好的命令行工具?

c# - 单声道中的 WCF Udp 发现

c# - Xamarin cycle 7 IOS IPA 输出现在在日期时间文件夹中

linux - Monodevelop 上的 F# : compiler doesn't understand valid Linux file path

c# - 如何使用 Microsoft.VisualBasic 引用在 MonoDevelop 中使用 IsNumeric 方法?

c# - MonoDroid 存在 ListView.ItemClick 和 AddFooterView 错误

c# - Mono 和 .NET dll 的互换性

c# - XAML 文件是否可移植到 Xamarin Macintosh?

view - 如何将对话框 View Controller 作为 subview 添加到 UIView 或反之亦然?