2017-02-23 4 views
0

.NETスタンダードAPIが実際にXamarin.Androidによって実装/サポートされているかどうかを確認するにはどうすればよいですか? NETStandard1.4ライブラリに実装されたWCF net.tcpクライアントがあります。私はこのライブラリをXamarin.Androidアプリから参照し、クライアントメソッドを呼び出そうとします。 コンパイルは正常ですが、クライアントメソッド呼び出しでNotImplementedExceptionをスローします。実際にXamarin.Androidに実装されている.NET標準のAPIは何ですか?

Xamarin.AndroidはいくつかのAPIを実装していませんが、.NETStandard1.4をまだサポートしていますか?私が使用したいすべてのクラス/メソッドは、Xamarinsのオンラインドキュメント(例:https://developer.xamarin.com/api/type/System.ServiceModel.ClientBase%3CTChannel%3E/)に記載されており、「実装されていません」という言及はありませんが、NotImplementedExceptionがあります。現時点では、それが本当にサポートされていないか、インストール/プロジェクトに何か混乱があるかどうかはわかりません。

はいの場合、誰かが単純にサポートすると主張でき、何でもできるのであれば、.NETスタンダードライブラリの目的は何ですか?完全のために

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); 
     } 
    } 
} 
+0

私が言及するのを忘れて、私はあなたがしようとする可能性があり – ArgusMagnus

+0

VS 2017 RCを使用していますこの問題が修正されているかどうかを確認するために最新のCycle 9リリース(現在入手可能)にアップグレードしますが、一般的にはXamarinプラットフォームの.NET Standardサポートはそれほど信頼性がありません。 .NET Core 2.0が利用可能な場合にのみ、完全に機能するかもしれません。 –

+0

.NET Core 2.0が利用可能になると、Xamarinが完全にサポートする可能性は何ですか? – ArgusMagnus

答えて

1

だから、Xamarin.Androidはいくつかを実装していないことを、することができAPIはまだ.NETStandard1.4を "サポート"していますか?

はい正しいです。実際、実装されていない領域にはNIE(実装されていない例外ではありません)を投げる古いプラットフォームがたくさんあります。

独自のプラットフォームを実装して実装全体にPlatformNotSupportedExceptionを投げると、「netstandardをサポートしている」とみなされます。したがってhttps://gist.github.com/davidfowl/8939f305567e1755412d6dc0b8baf1b7#gistcomment-1759645

あなたが最も可能性の高い特定の機能不足MonoのWCFスタックの問題に実行されている:一般的に

http://www.mono-project.com/docs/web/wcf/

、Xamarinプラットフォームがサポートするアーロン・ナースは、ここでは、この上の優れた洞察力を持っていますSilverlightランタイムに同梱されているWCFのクライアントサイドサブセットと同じです。これには、BasicHttpBindingクラスを使用するHTTPトランスポートプロトコル上のWCFテキストエンコードSOAPメッセージの最も一般的なエンコードおよびプロトコル実装が含まれます。さらに、WCFサポートでは、Windows環境でのみ使用可能なツールを使用してプロキシを生成する必要があります。

https://developer.xamarin.com/guides/xamarin-forms/web-services/consuming/wcf/

注:これらのタイプのいくつかのためにXamarinのドキュメントに注意してください。それらはMSDNから直接引き出され、BCLにリストされていればすべてがサポートされているわけではありません。より正確なアセンブリの一覧については、参照してください。

https://developer.xamarin.com/guides/cross-platform/advanced/available-assemblies/

をあなたはSilverlightのMSDNのドキュメントを見ていたほうが良いです:https://msdn.microsoft.com/en-us/library/system.servicemodel(v=vs.95).aspx

+0

最初の段落が間違っている可能性があります。多くのプラットフォームでは、 'NotImplementedException'ではなく、[ここ](https://github.com/dotnet/standard/blob/master/docs/faq.md)のように' PlatformNotSupportedException'を投げるべきです。 –

+0

@LexLiはい、あなたは正しいです。私は単なるWRT monoという概念を説明しようとしています:http://www.mono-project.com/docs/about-mono/compatibility/もっと理にかなって編集します。 –

+0

SlSvcUtil.exeを使用してSilverlight互換クライアントを生成しようとしましたが、全く同じ例外がスローされました。とにかく、あなたは私の質問に答えました、ありがとう。 – ArgusMagnus

関連する問題