Search code examples
c#referenceunrar

Unable to load DLL 'UNRAR.DLL': The specified module could not be found


I just downloaded UnRAR.dll from http://www.rarlab.com/rar_add.htm package includes C# sample project when I run in VS 2010 after selecting .rar file for extract I am getting below error message

Unable to load 'UNRAR.DLL'

and when I add reference unrar.dll I am getting below error

unrar.dll could not be loaded

Please help / point me what I am missing?


Solution

  • UnRAR.dll is not a .NET assembly so it cannot be used as a project reference.

    It is a native DLL so you'll have to use P/Invoke to access its methods or write a C++/CLI wrapper around it.

    There's some sample code in this MSDN forum thread that should provide a decent starting place and show the necessary approach.

    There also appears to be a fairly complete wrapper included in the Blue Mirror CD/DVD Indexer project.


    It should also be noted the SevenZipSharp includes support for this out-of-the-box. I haven't used it myself, but it might be worth checking into.