How to write FireFox extension with Visual Studio using C# programming language? - c#

I was wondering if it's possible to write Firefox extension using .Net Framework?
Had anybody such experience in writing Firefox extensions using C# programming language?
Any good sites or guidelines would be very helpful.
FFPlugin http://img81.imageshack.us/img81/3049/ffplugin.jpg
Here is an example of what I need. Extension to enter phone number and to send SMS Message.
I draw it in Paint, so I'm sorry for having no artistic touch.

Assuming you're asking about writing an extension (and not a plugin), the best place to get started is with the info at the Mozilla Dev Center.
Konamiman is correct: extensions are mostly XUL (an XML grammar) and Javascript, packaged into a ZIP file with the extension .xpi. The various links from the page I linked should answer basic questions, like the one you posted above:
https://developer.mozilla.org/en/Building_an_Extension
https://developer.mozilla.org/en/Extension_Frequently_Asked_Questions

Firefox extensions are written primarily in Javascript. See here: http://www.rietta.com/firefox/Tutorial/backend.html. So unless you can find a way to convert C# code/.NET Framework objects to Javascript, you are out of luck.

As has been observed by other respondents, Firefox extensions are primarily written in Javascript: but you're in luck, because Script# is a free tool that enables developers to author C# source code and subsequently 'compile' it into Javascript.

I'm not sure how you'd do for C#, but you can use XPCOM to call native code libraries: that's how the Glasser extension, for instance, is able to use the Windows-specific Aero effects.
IBM hosts a very good XPCOM tutorial at DeveloperWorks.

Related

Visual Studio intellisense and debug only in certain areas

I wrote a simple web-server that interprets c# inside HTML in real time (Like Razor, but it looks more like PHP style tags, just written in C#). Every C# code snippet is wrapped with <# and #>.
Now, I want to start writing a simple web application using it. Working with Notepad++ is painfully annoying, due to the fact it cannot really autocomplete C# well, and C# is a strict language (unlike PHP, Javascript or Python, in which developing in Atom or NP++ is extremely easy and natural).
So, the question:
I wanted to know if there is any way that I can edit those pages in Visual Studio, have all the autocomplete functionality, and in the same time let VS know that I want it to notice (colorize, syntax-check, etc) only code snippets wrapped in <# and #>.
How do I do that?
Visual studio 2015
Can be web developer or desktop version, I can any of them.
Thanks!
Visual Studio has a very powerful extension SDK, so you can achieve what you want by developing one or more extensions. If you're new to extension development, I'd suggest you take a look at this getting started guide first.
Microsoft has quite a few samples available on GitHub. At least the following two samples should be of interest to you.
Syntax coloring: Diff Classifier Sample
Custom programming language support: Ook Language Integration Sample
The Ook sample goes a bit further than what you actually need, but it has some elements that are usable to you.

How to write Firefox plugin with C# and mono?

this question was asked many times:
2004
http://lists.ximian.com/pipermail/mono-devel-list/2004-October/008213.html
2005
http://web.archiveorange.com/archive/v/0SAXwxPyVBCC31hdB3Mm
http://codeverge.com/netscape.mozilla.jseng/xpcom-and-mono-or-just-c/1577232
2007
http://forum.mozilla-russia.org/viewtopic.php?id=17385
http://rsdn.ru/forum/cpp.applied/2514021.flat
2009
http://ru-csharp.livejournal.com/153546.html
2010
https://forums.mozilla.org/viewtopic.php?f=13&t=1445
https://www.linux.org.ru/forum/development/5069566
and always without answers...
Language bindings page doesn't contain C# or mono (but does so for Java and Python):
https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings
There is some code - http://off.net/~shaver/mono/
But i don't see C++ part of it (and I think it is necessary as a "XPCOM Component Loader")
There is also something what is called MonoConnect
https://bugzilla.mozilla.org/show_bug.cgi?id=296672
But i didn't found it's docs in google.
I know that it is possible to implement plugin as CLR host as written here:
http://www.mono-project.com/docs/advanced/embedding/
but i don't want to reinvent the wheel,
that is why I am asking where to find an existing implementation of "Component Loader".
Here is your answer: http://lists.ximian.com/pipermail/mono-devel-list/2004-October/008215.html, first answer in your first link to a mailing list.
Here is a github link to the issue in MonoConnect. I just took some strings in the diff which is in the tracker(the link you provided) and searched in google for it, got a github repo.
As well as this: http://people.mozilla.org/~chofmann/l10n/tree/mozilla/extensions/mono/
As far as written code, this is the most you will probably get.

c#-doc-viewer for VisualStudio

c# offers a nice way to document your c#-code. But I don´t find any nice viewer. I search something like the java-doc-viewer in eclipse. This viewer allows you to browse in the java-doc just by moving your mouse over eg. a class-name.
Does someone know a good extension for Visual Studio 2010 that contains such a viewer?
I have the "Productivity Power Tools"-Extension installed. But it hasn´t a real doc-viewer either.
Edit:
Here is a picture of what I search:
And this is the best I can find for VisualStudio:
You try using CR_Documentor, if you don't mind installing Code Rush (alone for that purpose; you only need the free "DXCore" actually, checkout the project's homepage for more information).
Note that this tool doesn't require a prior generation of the documentation using tools like Sandcastle. It works by simply placing your cursor in a API comment block, e.g. that of a method.
Obviously, this has some drawbacks, for example, links to other items (e.g. <see/> or <seealso> will be rendered as a link, but don't work as such).
This is what it looks like:
I was using it once, way back when it was still maintained by the original author Lutz Roeder, and it did it's job well. I have not been using it since.
Update: You could also use ReSharper, which provides a "Quick Documentation" feature.
There isn't any built-in tool in VS for viewing the documentation of your code. You have to generate the documentation pages from the XML doc, using external tools.
Free tools:
Sandcastle is the most well known, it has a lot of features, but it doesn't seem to be maintained any more and it's quite difficult to use (although Sandcastle Help File Builder makes it significantly easier, and is still maintained).
docu is simpler to use, but not specific to .NET
Monodoc (from the Mono project)
Commercial tools:
VSdocman
Document! X
Doc-O-Matic
ForgeDoc: this one is quite new and looks very promising: very lightweight, simple to use, fast, good-looking output... It's also much cheaper than the others above
You can use NDoc to build the API documentation and generate help files (typically HTML files)
http://sourceforge.net/projects/ndoc/

Working with DjVu with .NET

I need to open DjVu files in my program, so I'm looking for some library. It must be free library, opensource would be better. When I tried to google it, I found only links to some books about .Net in *djvu format :D
This is an old question, but I wanted to include that I just uploaded a fully managed Djvu reader written in C#. If you make improvements please share. https://github.com/Telavian/DjvuNet
The following techniques may be useful.
First technique:
1) http://javadjvu.foxtrottechnologies.com/ djvu support for java
2) use ikvm.net to convert java code in dot net
it is tedious but can be tried and i think best method
Second technique:
http://twit88.com/blog/2009/02/28/open-source-windows-djvu-viewer/
a viewer to open djvu files
for more detail go through
sourceforge djvu
you can get basic details from here

C# plugin for Google Chrome

Can I communicate to Google Chrome in C#?
For writing a chrome plugin for example.
<Spoilers>
Quick short answer: No, because Extensions require JSON, JavaScript, and HTML.
</Spoilers>
Hi Tony,
There are multiple templates on the internet that you can download to build a chrome extension project using Visual Studio.
Downloading one of these templates just gives you the files and folders that you need which I call "the setup".
That won't let you build a Google extension using C#.
Andrey mentioned that there are libraries like Bridge.NET that will compile your code into HTML/JavaScript. That will help you write HTML and JavaScript using C#. You still need a manifest.json file.
I don't recommend that. That library is not designed for Chrome Extensions. Also, you will have to compile the code into JavaScript and store that JavaScript code in a JavaScript file. I recommend using HTML/JavaScript with no compilers when building your Chrome Extension.
You need to keep in mind that there are 3 main parts in a chrome extension. These are:
manifest.json
A JavaScript file
HTML file
There are multiple steps and it's not hard to build a google chrome extension. This link will give you the complete tutorial on developing a chrome extension with detailed explanation. This tutorial installs a template so that you can develop it in Visual Studio just like I mentioned before.
What I have done to address is use Simple Message Host, it will trigger an executable on the local machine that you code in c#, sending stdin messages and listening to stdout messages so you can build this host to use as a bridge, but like I said, it needs to be on your local network at least, and you have to do some editing in the windows registry, so it has its limitations.
But for the system I am working with, this solution worked perfectly because I have a controlled environment that I can set up all these prerequisites.
So, just to clarify, what I did here is:
Create a chrome extension with background.js opening up the listener to the website's javascript.
Add a registry in windows registry pointing to the path of the executable.
Create the executable in C# doing all your logic.
Send a response from the executable to the extension and then back to the website.
There are several guides on how to do this, so I won't detail these steps here so I don't replicate it.
But for the moment, it is the best way to do what you want, if you have control of your environment that is.
So, if your plugin (extension or chrome app) will work on a controlled environment, this is the way to go, otherwise, I would consider something related to ClickOnce perhaps or WebAssembly but that's not fully released yet.
Chrome own extension manager supports extensions written in js and html.
that said, to execute c# code within the extension you have two options:
Compile c# code to javascript code which then can be added as a normal javascript extension to chrome (take a look at scriptsharp)
Use c# as a back-end system. just like most of download managers:
for case 2 you need a c# application installed in client device(or in the cloud) listing to a specific port (using httplistener or self hosted webapi (you can use netcore) which do these steps
Listing to incoming requests
parse request data eg. json and do something with it
return the result to javascript extension which can display it to user or do other things with it.
The topic is quite old, but I'd like to share that sample:
https://github.com/Retyped/Demos/tree/master/ChromeDemo
In a few words, the sample is implemented in C#. The Retyped.chrome NuGet package provides bindings (Chrome API) for Bridge.NET projects. So yes, now you can implement your logic in C#, then C# code will be transparently compiled into JavaScript by Bridge.NET compiler.
With that approach you can build your Chrome extension on top of .NET Framework as well as utilize thousands of JavaScript libraries.

Categories