我怎樣才能瞭解是否有.NETStandard API實際上是實現/支持Xamarin.Android?我在.NETStandard1.4庫中實現了一個WCF net.tcp客戶端。我從Xamarin.Android應用程序引用此庫並嘗試調用客戶端方法。 它編譯罰款,但拋出的客戶端方法調用NotImplementedException
。什麼.NETStandard的的API在Xamarin.Android實際執行?
因此可以說,它是,那Xamarin.Android沒有實現部分API,但仍然是「支持」 .NETStandard1.4?林問,因爲我不是能找到什麼說,它不支持,所有的類/方法,我想使用Xamarins在線實況(例如,https://developer.xamarin.com/api/type/System.ServiceModel.ClientBase%3CTChannel%3E/),並沒有提及「未實現」的記錄,但我得到了NotImplementedException
。目前我無法確定它是否真的不被支持,或者是否有某些東西與我的安裝/項目混淆。
如果是,那麼.NETStandard庫的目的究竟是什麼,如果任何人只是聲稱支持它,並拋出NotImplementedException
?
出於完整性:
Xamarin.Android應用:
// 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庫:
// 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);
}
}
}
我忘了提,我使用VS 2017年RC – ArgusMagnus
您可以嘗試升級到最新的Cycle 9發行版(今天剛剛發佈)以查看此問題是否已得到解決,但一般來說,Xamarin平臺上的.NET標準支持尚不可靠。它只有在.NET Core 2.0可用時纔可以完全工作。 –
您可以說一旦Xamarin完全支持.NET Core 2.0的可能性嗎? – ArgusMagnus