将 .NET GZipStream 类与 Mono 结合使用
我正在尝试从 GZipStream 类。使用命令 gmcs gzip.cs
,我收到错误消息。 gzip.cs 与 msdn 的来源相同。
看来编译的时候需要添加引用。缺少什么?
gzip.cs(57,32): error CS1061: Type `System.IO.FileStream' does not contain a definition for `CopyTo' and no extension method `CopyTo' of type `System.IO.FileStream' could be found (are you missing a using directive or an assembly reference?)
/Library/Frameworks/Mono.framework/Versions/2.10.1/lib/mono/2.0/mscorlib.dll (Location of the symbol related to previous error)
gzip.cs(86,40): error CS1061: Type `System.IO.Compression.GZipStream' does not contain a definition for `CopyTo' and no extension method `CopyTo' of type `System.IO.Compression.GZipStream' could be found (are you missing a using directive or an assembly reference?)
/Library/Frameworks/Mono.framework/Versions/2.10.1/lib/mono/gac/System/2.0.0.0__b77a5c561934e089/System.dll (Location of the symbol related to previous error)
Compilation failed: 2 error(s), 0 warnings
已解决
我应该使用“dmcs”,而不是“gmcs”才能使用 .NET 4 功能。
I'm trying to build an example from GZipStream Class. With the command gmcs gzip.cs
, I got error messages. gzip.cs is the same source from the msdn.
It seems that I need to add reference when compiling. What's missing?
gzip.cs(57,32): error CS1061: Type `System.IO.FileStream' does not contain a definition for `CopyTo' and no extension method `CopyTo' of type `System.IO.FileStream' could be found (are you missing a using directive or an assembly reference?)
/Library/Frameworks/Mono.framework/Versions/2.10.1/lib/mono/2.0/mscorlib.dll (Location of the symbol related to previous error)
gzip.cs(86,40): error CS1061: Type `System.IO.Compression.GZipStream' does not contain a definition for `CopyTo' and no extension method `CopyTo' of type `System.IO.Compression.GZipStream' could be found (are you missing a using directive or an assembly reference?)
/Library/Frameworks/Mono.framework/Versions/2.10.1/lib/mono/gac/System/2.0.0.0__b77a5c561934e089/System.dll (Location of the symbol related to previous error)
Compilation failed: 2 error(s), 0 warnings
SOLVED
I should use 'dmcs', not 'gmcs' in order to use .NET 4 functions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Stream.CopyTo 仅在 .NET 4 中出现 - 它可能还没有在 Mono 中(或者您可能需要更新的版本)。
不过,编写类似的扩展方法很容易:
Stream.CopyTo
only arrived in .NET 4 - it may not be in Mono yet (or perhaps you need a more recent version).It's easy to write a similar extension method though: