-3

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

rockeye
  • 2,765
  • 2
  • 30
  • 44
Exception
  • 8,111
  • 22
  • 85
  • 136
  • Your edit is basically just a duplicate of [this question](http://stackoverflow.com/questions/2652034/a-simple-hello-world-npapi-plugin-for-google-chrome). You should spend some time with the resources given there, and then ask new specific questions if you are still having trouble. – smorgan Jan 02 '12 at 14:58
  • @smorgan Thanks for your comment. And that Question was answered when Google chrome was a child and the Chrome versions have been changed. I have asked the Question for latest code samples... :-) – Exception Jan 02 '12 at 15:10
  • NPAPI isn't a Chrome API, it's a very stable cross-browser API, and as such it changes *very* slowly; the Chrome version is irrelevant. There have been no significant changes to NPAPI since the question I pointed you to. Everything in the top-voted answer is still the best answer to your question; no amount of bounty will cause there to be better answers. – smorgan Jan 03 '12 at 10:18

2 Answers2

3

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

Community
  • 1
  • 1
Mohamed Mansour
  • 39,445
  • 10
  • 116
  • 90
  • I have seen many of your answers in stackoverflow and I am glad to have your response here.. I have seen them but they are referring to MDN. Where information is like finding salt in sea water. I hope you can help me with little more explanation. Please help me on this. I am struggling for this to understand. I dont want to use firebreath because I am only targeting Chrome. – Exception Jan 02 '12 at 15:08
  • Sol, The first thing I saw in your question is that your using C# which is incorrect, you need to use C++ for NPAPI and the link I specified above is a simple Hello World plugin that should work. Try understanding that (there is a blog link there that is extremely good), and run the hello world. What @smorgan said regarding calling methods is what you should normally do. – Mohamed Mansour Jan 02 '12 at 18:08
2

NPAPI plugins don't add utility classes to your JS namespace, they allow you to instantiate <object>/<embed> elements. You need to instantiate your plugin in HTML, and then call methods on that plugin element.

smorgan
  • 20,228
  • 3
  • 47
  • 55