You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by GitBox <gi...@apache.org> on 2020/09/10 13:29:24 UTC

[GitHub] [lucenenet] NightOwl888 commented on issue #336: Method not found: 'System.IO.MemoryMappedFiles.MemoryMappedFile System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile

NightOwl888 commented on issue #336:
URL: https://github.com/apache/lucenenet/issues/336#issuecomment-690289515


   4.8.0-beta00006 is more than a year old and has not been tested with .NET Core 3.1. Could you please confirm this problem exists in the latest version, 4.8.0-beta00011?
   
   That being said, it seems unlikely that this problem can be caused by the released binaries unless you are using a really old version of NuGet to install them (thus getting the wrong target DLL in your project) or you are using the source code directly without the proper conditional compilation symbols. There is a conditional section to remove the `memoryMappedFileSecurity` parameter when using .NET Standard. For 4.8.0-beta00006, .NET Standard 2.0 would normally be the target that is installed when the consuming project targets .NET Standard 3.1 and you are using a recent version of NuGet to install it.
   
   ```c#
               if (input.memoryMappedFile == null)
               {
                   input.memoryMappedFile = MemoryMappedFile.CreateFromFile(
                       fileStream: fc, 
                       mapName: null, 
                       capacity: length, 
                       access: MemoryMappedFileAccess.Read,
   #if !NETSTANDARD
                       memoryMappedFileSecurity: null,
   #endif
                       inheritability: HandleInheritability.Inheritable, 
                       leaveOpen: true); // LUCENENET: We explicitly dispose the FileStream separately.
               }
   ```
   
   Of course, if compiling from source, this (unintuitively) means that you will need to use a `NETSTANDARD` compilation symbol to target .NET Core 3.1 directly, otherwise it will call the wrong overload.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org