Giter Site home page Giter Site logo

Comments (3)

arklumpus avatar arklumpus commented on June 11, 2024

Hi! Thanks for pointing this out, I didn't realise strong naming was still around (I have been using mostly .NET Core/.NET, and strong naming doesn't really matter anymore). Assuming it won't break anything, I will try to strong name-sign the next release!

In the meantime, assuming you don't want to disable strong naming in your project, you don't need to build from source; you can use the following workaround:

  1. Uninstall the MuPDFCore NuGet package from your project.

  2. Download the MuPDFCore nupkg file, rename it to have a .zip extension and extract it somewhere.

  3. Now, you need to sign the DLL to give it a strong name. I assume you have a .snk file that you have been using to sign your project:

    • Open the Developer Command Prompt that is installed with Visual Studio and double-check that you have the ilasm, ildasm and sn tools.

    • Use cd to change directory to the extracted nupkg file.

    • Execute:

      sn -vf lib\netstandard2.0\MuPDFCore.dll
      

      This should show a message saying lib\netstandard2.0\MuPDFCore.dll does not represent a strongly named assembly - just to confirm what we're working with.

    • Run:

      ildasm /all /out=lib\netstandard2.0\MuPDFCore.il lib\netstandard2.0\MuPDFCore.dll
      

      This will disassemble the MuPDFCore DLL and produce a file called MuPDFCore.il (containing the disassembled code) and another file called MuPDFCore.res (containing the resources) in the lib\netstandard2.0 folder.

    • Unfortunately, the ilasm tool has a bug when dealing with NaNs, so we need to make a small change in the IL file. Open the MuPDFCore.il file in a text editor, and replace every occurrence of ldc.r8 -nan(ind) with ldc.r8 (00 00 00 00 00 00 F8 FF). There should be 10 occurrences. Save and close.

    • You can now rebuild the DLL signing it with the strong name key with this command:

      ilasm /dll /key=path\to\key.snk /resource=lib\netstandard2.0\MuPDFCore.res lib\netstandard2.0\MuPDFCore.il
      

    This will overwrite the lib\netstandard2.0\MuPDFCore.dll library with the signed one.

    • If you now execute:
      sn -vf lib\netstandard2.0\MuPDFCore.dll
      
      This should show a message saying Assembly 'lib\netstandard2.0\MuPDFCore.dll' is valid, confirming that everything has worked.
  4. You can finally add the reference back into the project. In Visual Studio, add a reference to the signed MuPDFCore.dll.

  5. Finally, right click on the project in the Solution Explorer and select Add > Existing item.... Locate and select the MuPDFWrapper.dll file for your architecture (if you're building for Any CPU or x86, select the MuPDFWrapper.dll file in the runtimes\win-x86\native folder within the extracted NuGet package, if you're building for x64 select instead the one in runtimes\win-x64\native). After adding the item to the project, set the Copy to Output Directory action to Copy if newer in the file properties.

You should now be able to debug and execute your program.

I hope this makes sense, let me know if something isn't clear or if you have any further questions!

from mupdfcore.

wickyhu avatar wickyhu commented on June 11, 2024

Hi,

Thank you very much for the information.
Issue resolved.

Best Regards
Wicky

from mupdfcore.

arklumpus avatar arklumpus commented on June 11, 2024

Hi, starting from the new version 1.8.0, the library is now strong-name signed.

I'm closing this issue, let me know if you have any more problems!

from mupdfcore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.