C#なんぞ

C#に関するあれこれ。現在は「Raspberry PiをC#でプログラミング!」しようとしています!

publicにできない!

publicがだめならinternalで!

csharpwhat.hatenablog.com

前回の記事で紹介したクラスのアクセス指定子はinternalですが、これをpublicにするとビルドエラーが出ます!

error WME1038: Method 'IntervalTimer.Delay(System.TimeSpan)' has a parameter of type 'System.Threading.Tasks.Task' in its signature. Although this type is not a valid Windows Runtime type, it implements interfaces that are valid Windows Runtime types. Consider changing the method signature to use one of the following types instead: ''.

IntervalTimer.DelayシグネチャーにWindowsランタイム型でないクラスのTaskが入っているから、ということのようです。

Windows ランタイム コンポーネントのエラー条件の診断を読むと、

コンポーネントのパブリック インターフェイスWindows ランタイム 型のみを公開する必要があります。

とあります。

Windowsランタイム型でないクラスを「公開」してはいけないようです。publicでだめなら、というわけでinternalにするとOKですね!

いろいろ難しい!