Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot access a closed stream #24

Closed
YakaryBovine opened this issue Apr 24, 2022 · 4 comments
Closed

Cannot access a closed stream #24

YakaryBovine opened this issue Apr 24, 2022 · 4 comments
Labels
Area-Build Related to project War3Net.Build or War3Net.Build.Core Area-Mpq Related to project War3Net.IO.Mpq

Comments

@YakaryBovine
Copy link

Hi, getting this error when I try to build my map.

Unhandled exception. System.ObjectDisposedException: Cannot access a closed Stream. at System.IO.MemoryStream.Seek(Int64 offset, SeekOrigin loc) at War3Net.IO.Mpq.MpqStream.LoadSingleUnit() at War3Net.IO.Mpq.MpqStream.BufferData() at War3Net.IO.Mpq.MpqStream.ReadInternal(Byte[] buffer, Int32 offset, Int32 count) at System.IO.BinaryReader.InternalRead(Int32 numBytes) at System.IO.BinaryReader.ReadInt32() at War3Net.Build.Info.MapInfo.ReadFrom(BinaryReader reader) at War3Net.Build.Info.MapInfo..ctor(BinaryReader reader) at War3Net.Build.Extensions.BinaryReaderExtensions.ReadMapInfo(BinaryReader reader) at War3Net.Build.Extensions.MpqArchiveBuilderExtensions.SaveWithPreArchiveData(MpqArchiveBuilder mpqArchiveBuilder, String fileName, MpqArchiveCreateOptions createOptions) at War3Net.Build.MapBuilder.Build(String path, MpqArchiveCreateOptions createOptions) at AzerothWarsCSharp.Launcher.Program.Build(String baseMapPath, String projectFolderPath, Boolean launch) in C:\Users\Zak\source\repos\AzerothWarsCSharpNew\src\AzerothWarsCSharp.Launcher\Program.cs:line 146 at AzerothWarsCSharp.Launcher.Program.MakeDecision() in C:\Users\Zak\source\repos\AzerothWarsCSharpNew\src\AzerothWarsCSharp.Launcher\Program.cs:line 83 at AzerothWarsCSharp.Launcher.Program.Main() in C:\Users\Zak\source\repos\AzerothWarsCSharpNew\src\AzerothWarsCSharp.Launcher\Program.cs:line 59

This issue is new as of 5.4.2. If I downgrade to 5.4.1 the problem goes away.

@Drake53
Copy link
Owner

Drake53 commented Apr 24, 2022

Only changed that one thing in v5.4.2 so I think it's caused by a change in War3Net.IO.Mpq, War3Net.Build.Core v5.4.1 depended on War3Net.IO.Mpq v5.4.0, but latest version is v5.4.3
Since I skipped uploading v5.4.1 and v5.4.2 and nuget is being annoying about 2fa I'm attaching the packages here, I assume you know how to add a local folder source for nuget packages. Can you try out in which version the issue was introduced? (By using War3Net.Build v5.4.1 in combination with War3Net.IO.Mpq v5.4.1 / v5.4.2 / v5.4.3)
war3net.io.mpq.zip

@YakaryBovine
Copy link
Author

YakaryBovine commented Apr 25, 2022

Yep, no problem.
I only experience the issue with War3Net.IO.MPQ version 5.4.3. If I downgrade it to 5.4.2 or 5.4.1, everything works fine. I did all 3 of my tests with War3Net.Build 5.4.1 as instructed.

@Drake53
Copy link
Owner

Drake53 commented Apr 25, 2022

The issue was in War3Net.Build.Core after all, only occured since War3Net.IO.Mpq v5.4.3 because reading from the mpqstream for mpq files with SingleUnit flag (which includes files which are based on (in this case) a memorystream instead of an mpq archive) was made lazy so it happens on first read instead of in the ctor. At that point the base memorystream was already disposed.
Fixed in v5.4.3: 73cfc61

@Drake53 Drake53 added Area-Build Related to project War3Net.Build or War3Net.Build.Core Area-Mpq Related to project War3Net.IO.Mpq labels Apr 25, 2022
@YakaryBovine
Copy link
Author

Awesome, I can compile again. Cheers. FYI I had to add War3Net.Build.Core 5.4.3 to my package references manually - the implicit reference from War3Net.Build 5.4.2 didn't seem to cut it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Build Related to project War3Net.Build or War3Net.Build.Core Area-Mpq Related to project War3Net.IO.Mpq
Projects
None yet
Development

No branches or pull requests

2 participants