dokan-dev / dokan-dotnet

Dokan DotNet Wrapper
http://dokan-dev.github.io
MIT License
462 stars 116 forks source link

why sometimes the readfile report an error: “System.ArgumentNullException:“Value cannot be null.” #257

Closed NavigatorXia closed 4 years ago

NavigatorXia commented 4 years ago

I use the sample "mirror" to do the test, and its readfile has code as following: if (info.Context == null) // memory mapped read { 。。。 } else // normal read { var stream = info.Context as FileStream; lock (stream) //Protect from overlapped read .... the error occurred in "lock(stream)", it shows stream is null(the info.Context also is null), but we have checked it by “if (info.Context == null) ”

Liryna commented 4 years ago

It would mean the value was not or no longer a stream in the context. Do you have a way to reproduce it? Could it be a directory someone try to read? Directory do not have any context stream

NavigatorXia commented 4 years ago

It's not a directory, I'm not sure if there are some problem in multi-thread or async read/write.

and i also get a error like: System.ObjectDisposedException:“Cannot access a closed file.”

BTW, I use it to run a developed edition of UE4(Unreal Engine).

Liryna commented 4 years ago

@NavigatorXia It might be a read happening after close.

The logic missing here would be to reopen the stream during read / write if the stream is invalid.

Liryna commented 4 years ago

@NavigatorXia Did I answer your question correctly?

NavigatorXia commented 4 years ago

Thanks for your reply.