Search code examples
c#c++google-chrome-extensionnpapi

How to call npapi plugin method in extension


I have a test .dll file using C# with the following details

 Name : TestLibrary.dll
 Namespace name : TestLibrary
 Class Name : AddClass
 Method name : add(accepts two parameters)
 Language used : C#

I gave lugin path in manifest.json as below

 plugins : [{"path":"TestLibrary.dll", "public": true}]  

And called like below

 var result = TestLibrary.AddClass.add(12,34)   

But it returns me nothing. Please help me to correct this code. Please provide me simple NPAPI plugin example with hello world program with NPAPI plugin in any example. I am confused with parameters / details / references need to be provided inside NPAPI plugin


Solution

  • You cannot use C# to create a NPAPI Plugin. You must have a C++ library that exports the following entry points:

    LIBRARY   my_plugin.dll
    
    EXPORTS
      NP_GetEntryPoints     @1
      NP_Initialize         @2
      NP_Shutdown           @3
    

    These entry points are the core to the NPAPI architecture. For examples, refer to the following answer A simple hello world NPAPI plugin for Google Chrome