The path is not of a legal form.

Oct 4, 2011 at 9:17 PM

Hi !

I have been using SevenZipSharp for a while now in some projects here at work.

We recently tried to use it in a SQL CLR Stored Procedure and it fails on the SetLibraryPath with the error mentionned above.

System.TypeInitializationException: The type initializer for 'SevenZip.SevenZipLibraryManager' threw an exception. --->
System.ArgumentException: The path is not of a legal form.     
at System.IO.Path.NormalizePathFast(String path, Boolean fullCheck)    
at System.IO.Path.NormalizePath(String path, Boolean fullCheck)     
at System.IO.Path.GetDirectoryName(String path)     
at SevenZip.SevenZipLibraryManager..cctor()  

The application perfectly works as a Console. But it fails when used as a SQL CLR Store Procedure.

Any ideas ?

 

Thanks

--
Nicholas

Nov 13, 2013 at 6:04 PM
Edited Nov 13, 2013 at 6:05 PM
I'm currently trying to work through this issue. Is there a solution to this?

I'm using the below code to try and deploy the sevenzipsharp.dll from an embedded resource. My application fails when I try to set the 7zip.dll library path.

code:
SevenZipExtractor.SetLibraryPath("\7z.dll");

link
http://www.codeproject.com/Articles/528178/Load-DLL-From-Embedded-Resource



Nick (the name is just a coincidence)
Jan 24, 2014 at 1:50 PM
Hi guys.
I've run into this kind of issue, the last days, and it took me quite a while to find a solution.
Even if it's not a perfect one.

I had to add this line to my code
ConfigurationManager.AppSettings["7zLocation"] = sevenZipPath;

I went here after reading the source code of SevenZipSharp and I found this line:

__

internal static class SevenZipLibraryManager
...
    private static string _libraryFileName = ConfigurationManager.AppSettings["7zLocation"] ??
        Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "7z.dll");
__


Without the previous line the code was blowing with an exception of invalid path when I called the method bellow.
I can assure you that the path is a perfect valid path, I've a lot of verifications before calling this line, and If I get a bad path I must throw an exception . . .

SevenZipBase.SetLibraryPath(sevenZipPath);

From your experience do you have any ideas of other workaround ? Is it related to how I'm referencing the DLL ?
Thanks in advance for your help.