如何确定Xamarin.Android是否实际实现/支持.NETStandard API?我有一个在.NETStandard1.4库中实现的WCF net.tcp客户端。我从Xamarin.Android应用程序引用此库并尝试调用客户端方法。
它编译得很好,但在客户端方法调用上抛出NotImplementedException
。
所以,Xamarin.Android并没有实现某些API,但仍然支持" .NETStandard1.4?我问,因为我无法找到任何说它不受支持的内容,我想要使用的所有类/方法都记录在Xamarins在线文档中(例如https://developer.xamarin.com/api/type/System.ServiceModel.ClientBase%3CTChannel%3E/)并且没有提及"未实现&# 34;,但我得到了NotImplementedException
。目前,我无法判断它是否真的不受支持,或者是否存在与我的安装/项目有关的事情。
如果是,那么.NETStandard库的目的究竟是什么,如果有人可以声称支持它并抛出NotImplementedException
那么?
为了完整性:
Xamarin.Android app:
// MainActivity.cs
using Android.App;
using Android.Widget;
using Android.OS;
using System.ServiceModel;
namespace App1
{
[Activity(Label = "App1", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
// SetContentView (Resource.Layout.Main);
var endpoint = new EndpointAddress("net.tcp://192.168.192.189:8550/iQOSApp_AppService");
var binding = new NetTcpBinding(SecurityMode.None);
var client = new iQOSApp.Clients.AppContractClient(binding, endpoint);
int n = client.GetData(0); // NotImplementedException
}
}
}
.NETStandard Library:
// Clients.cs
//------------------------------------------------------------------------------
// <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>
//------------------------------------------------------------------------------
namespace iQOSApp.Clients
{
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName = "iQOSApp.Clients.IAppContract")]
public interface IAppContract
{
[System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IAppContract/GetData", ReplyAction = "http://tempuri.org/IAppContract/GetDataResponse")]
int GetData(int value);
[System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IAppContract/GetData", ReplyAction = "http://tempuri.org/IAppContract/GetDataResponse")]
System.Threading.Tasks.Task<int> GetDataAsync(int value);
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public interface IAppContractChannel : iQOSApp.Clients.IAppContract, System.ServiceModel.IClientChannel
{
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class AppContractClient : System.ServiceModel.ClientBase<iQOSApp.Clients.IAppContract>, iQOSApp.Clients.IAppContract
{
public AppContractClient()
{
}
public AppContractClient(string endpointConfigurationName) :
base(endpointConfigurationName)
{
}
public AppContractClient(string endpointConfigurationName, string remoteAddress) :
base(endpointConfigurationName, remoteAddress)
{
}
public AppContractClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
base(endpointConfigurationName, remoteAddress)
{
}
public AppContractClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress)
{
}
public int GetData(int value)
{
return base.Channel.GetData(value);
}
public System.Threading.Tasks.Task<int> GetDataAsync(int value)
{
return base.Channel.GetDataAsync(value);
}
}
}