Uri*_*pov 1 c# protobuf-net unity-game-engine windows-phone-8
protobuff-net中的Deserialize方法将Stream作为参数。在我以前使用FileStream并通过它并使其起作用之前,但是现在我必须使用StreamReader,因为我正在将应用程序移植到Windows应用商店/电话中。我收到以下错误:
error CS1503: Argument 1: cannot convert from 'System.IO.StreamReader' to 'System.IO.Stream'
Run Code Online (Sandbox Code Playgroud)
另外这是一个unity3d项目,我得到的另一个错误是:
error CS4028: 'await' requires that the type 'Windows.Foundation.IAsyncOperation<Windows.Storage.StorageFolder>' have a suitable GetAwaiter method. Are you missing a using directive for 'System'?
Run Code Online (Sandbox Code Playgroud)
这很奇怪,因为我将代码包装在#if NETFX_CORE #endif
了其中,这是我正在使用的包含项:
#if NETFX_CORE
using System.IO;
using System.Threading.Tasks;
using Windows.Storage;
#endif
Run Code Online (Sandbox Code Playgroud)
从逻辑上讲,您不能-a StreamReader是用于文本数据,而protobuf数据是二进制数据。目前尚不清楚从何处获得StreamReader信息,但是您应该寻找为二进制数据设计的API。
实际上,您可能可以使用它StreamReader.BaseStream来获取基础流,但是StreamReader无论如何您都不应该创建一个从非文本数据中读取数据的方法……并且构造阅读器可能会尝试从流中读取文本数据并抱怨如果找不到的话...