issue with reference to .dll

488 Views Asked by At

currently making a small program by using WinForms and 7zip unpacker. To make it easier added reference to "SevenZipSharp.dll" everything work good, untill i wanted to publish(debug) project. When i move the ".exe" file in Desktop got error :

System.IO.FileNotFoundException: Could not load file or assembly 'X' or one of its dependencies".

I embedded resource set in .dll file + Copy Local: set to true

How i can make this programs to work without .dll in Current directory.

EDIT

I did it by use

System.Reflections

Solution here

But i got now another problem with

     System.TypeInitializationException: 'The type initializer for 'SevenZip.SevenZipLibraryManager' threw an exception.. ---> System.ArgumentException:  Path has an illegal format
   w System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   w System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   w System.IO.Path.InternalGetDirectoryName(String path)
   w System.IO.Path.GetDirectoryName(String path)
   w SevenZip.SevenZipLibraryManager..cctor()
   --- End of inner exception stack trace ---

   w SevenZip.SevenZipLibraryManager.SetLibraryPath(String libraryPath)
   w SevenZip.SevenZipBase.SetLibraryPath(String libraryPath)
1

There are 1 best solutions below

5
On

You would want to have the referenced libraries in the same folder or else you can also register them in GAC.