Not able to use this library with IIS based Web Service or WebApi

Issue #1 wontfix
Robert Važan repo owner created an issue

Originally reported by GAURAV KRISHNA.

I'm using this library in ASP.NET WebApi and its causing failures.

System.TypeInitializationException: The type initializer for 'Snappy.NativeProxy' threw an exception. ---> System.UnauthorizedAccessException: Access to the path 'C:\Windows\TEMP\Snappy.NET-2.10.0.0\snappy32.dll' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.File.InternalReadAllBytes(String path, Boolean checkHost)
   at Snappy.NativeProxy..ctor(String name) in d:\BuildAgent\work\af38a6d7664cf70c\client\clr\DataFabric.NET\DataFabricClientFactory.cs:line 0
   at Snappy.Native32..ctor() in d:\BuildAgent\work\af38a6d7664cf70c\client\clr\DataFabric.NET\DataFabricClientFactory.cs:line 0
   at Snappy.NativeProxy..cctor() in d:\BuildAgent\work\af38a6d7664cf70c\client\clr\DataFabric.NET\DataFabricClientFactory.cs:line 0
   --- End of inner exception stack trace ---
   at Snappy.SnappyCodec.GetMaxCompressedLength(Int32 inLength) in d:\BuildAgent\work\af38a6d7664cf70c\client\clr\DataFabric.NET\DataFabricClientFactory.cs:line 0
   at Snappy.SnappyCodec.Compress(Byte[] input) in d:\BuildAgent\work\af38a6d7664cf70c\client\clr\DataFabric.NET\DataFabricClientFactory.cs:line 0

Looking through the code it is due to use of GetTempPath() api in NativeProxy ctor.

protected NativeProxy(string name)
        {
            var assembly = Assembly.GetExecutingAssembly();
            var folder = Path.Combine(Path.GetTempPath(), "Snappy.NET-" + assembly.GetName().Version.ToString());
            Directory.CreateDirectory(folder);
            var path = Path.Combine(folder, name);
      }

Comments (2)

  1. Log in to comment