I have an application that I'm developing that deals with files of any type. I would like the user to be able to right click on any type of file in the Finder and have my menu option show up. I understand you have to add your application as a service to do this, however, whatever I put in the service settings in my Info.plist doesn't do the trick. I do register my application as a service with OS X, and I know it works because under service preferences my application's service shows up. However, I don't think I'm passing it the right type of parameters, because I can't activate my service by right-clicking on a file.
Any help would be deeply appreciated.
Did you take a look at the Apple documentation?
Also, this might be useful: Writing a Snow Leopard Service for Finder.app
Related
I have an application that is a Windows Service application. It currently reads an XML file for it's configuration and the code works off those settings.
I have created a separate project that is a Windows Forms application (typical windows app). This app is a GUI interface into the configuration settings (changed from XML to database, but that is relatively unimportant).
What I need to do is:
Integrate the 2 projects
Add a system tray icon to pop up the form
I'm unsure exactly how to proceed on this and wanted to get some advice before messing things up.
You can't integrate these two things (entirely). A service is designed to run without a GUI of any kind (there is a work around to allow desktop interaction but this is messy and clunky and will cause you more problems than it solves)
It sounds like you just need to use the code from the service in the forms application. This should be a simple copy and paste operation.
To show an icon in the system tray is pretty easy:
Create a program to run from the system tray
how to put an .net application in system tray when minimized?
I have a program that is written in VB.NET. It is currently interactive in that the user will click on some buttons on the form and click "GO" and it will do it's stuff.
I would like to set this up via a service on a Windows PC and instead of having user inputs via clicks have all the information in a config file.
It is my understanding that I can set this up as a service with some "parameters" on the call line, etc. and get other information from the config file.
Can someone advise me on how to do this?
Thanks
As far as I'm aware the software must have a ServiceInstaller class to install the service and a Service class that inherits from ServiceBase.
This would enable Windows to install, stop and start the service via the command line and services menu respectively.
Here's a simple example
You will need to make some small changes to convert your program to a Windows Service.
First, you will want to remove the user interface entirely - services shouldn't have a user interface.
You'd then build in the service plumbing required. Visual Studio includes a design experience specifically for creating Windows Services. For details on this, see the Creating a Windows Service Application in the Component Designer.
I have created an application that exposes a OSX service for certain file by adding an NSService entry into my applications info.plist (as in http://www.macosxautomation.com/services/learn/), but I find that upon installing my application on a new machine the service doesn't show up quickly in the finder right click context menu.
I know that this is because pasteboard services hasn't re-indexed the /Applications folder and "discovered" the newly installed service.
I also know that I can force a re-index and discovery by manually running /System/Library/CoreServices/pbs.
The question here is what is the best way to ensure that my service shows up as quickly as possible for users who are installing my application for the first time.
I could execute a system call to "/System/Library/CoreServices/pbs" when my application starts up --If the user immediately starts my application--, but that only partly solves the problem (in addition I wonder if there is a better Cocoa API based way of doing this).
If my application is generally only accessed via the context menu, a user will never think to go out and start the application in the first place. They will only think it is broken when the context menu isn't there.
I am not distributing my application with an installer. I am simply providing a bundle that can be dragged and dropped into /Applications (as I believe Apple usually suggests).
Is there a way to expedite the process of service discovery when doing an installation in this fashion, so that there isn't any period of time where the user is without the newly installed service?
As a side note, it appears that the problem may not exist in 10.8 (or at least be as pronounced). Apple may have made this indexing happen more quickly in their most recent release.
I've actually ended up using
system("killall pbs;/System/Library/CoreServices/pbs -flush");
in one of my apps, just as you describe, though it's a long time ago, when 10.5 was in question as well.
You might want to try this function, however:
void NSUpdateDynamicServices(void)
which according to the documentation acts just like flushing pbs, but is a cleaner solution.
Also, if (according to your description), the app is nothing but a service, consider making it a really just a service - see (Installing the Service)
To build a standalone service, use the extension .service and store it in Library/Services.
I created a new WCF Application. It has a svc file & a code behind, When I try to debug (F5) then I see the following.
If svc file is open & press F5 then it opens the web browser
If code behind file is currently open & press F5 then WCF Test client opens.
Why there are different behavior? I do not want to use Test Client, how to disable it in the app so that it would not come again.
Atul Sureka
Open your project properties, go to the Debug tab, under start options you will see something like
/client:"WcfTestClient.exe"
delete that line.
For a WCF Service Application and WCF Workflow Service Application you need to modify the .csproj.user file. A full write up can be found here.
The key part is
<WebProjectProperties>
<EnableWcfTestClientForSVC>False</EnableWcfTestClientForSVC>
</WebProjectProperties>
I have been down this road MANY times over the years at different companies.... I forget and I found this page and while it is good advise for some, not helpful for me.
What DID fix this for a WCF application for me is this:
Note: Visual Studio 2013 FYI
1. Right click on the your WCF project and click Properties
2. Click on left "Web" link/tab --> Notice the Start Action Section
3. Check Radio Button "Specific page"
4. Enter your .svc example Service1.svc
5. Set project as startup and either hit F5 or right click and debug
6. Now the WCF Test Client launches (for me at least)
Hope this helps someone else.
Right Click WCF Project -> Select Properties -> Debug
In Debug, you can see the Command Line arguments specified as /client:"WcfTestClient.exe"
Removing this won't fire up the test client when you run the service.
Regards,
Venkatarajan Arthanari
for future view ... when i was in a svc file, and hit f5, it always start this utility ...
i try the param in the project file, don't work ...
then, in property, i change the setting in web, from Current page, to my default page :)
now i don't have this utility popping each time :)
To control the WCF Test Client auto-launch in Visual Studio 2015/2017 you can do the following:
Right-click the WCF Service Project in Solution Explorer, choose Properties, and click WCF Options tab. Clear the checkbox Start WCF Service Host when debugging another project in the same solution (that check box is enabled by default).
It is easier than that.
1.- Open Project properties.
2.- Debug tab
3.- Remove the "/client:"WcfTestClient.exe" appearing in the "comand line arguments" textbox.
4.- Done!
If you want to run the project in a browser,
Go to the properties of the project
Click -> Web
In the servers section, mention the iis (iisexpress, local IIS) and specify the URL "http://localhost:11111/"
this will take the program to the browser
To take it only to wcf test client,
follow the above steps, but the URL should point to the service.
http://localhost:11111/yourservice.svc .. will do.
Thank you
To disable WCF Service Test Client
In Solution Explorer right click on "Solution 'YourServiceName' "
and go to properties
In "Common Properties" select "startup project"
Enable "Current Selection" Radio button
Click "Apply"
Click "ok"
Now open which ever service you want to run, and hit F5. It will run the current service.
I want to pop a browser with a given url from within a windows service. Like so:
System.Diagnostics.Process.Start("http://www.venganza.org/");
Works fine when running in a console but not from within the service. No error messages, no exceptions, the Process.Start() command just seem to do nothing. It smells of some security issue, maybe something with the service properties and/or logon options? Annoying stuff this... Anybody? (Oh, and on windows 7/.NET framework 3.5.)
A service should never pop up anything to the user. Don't do this with a service.
You will problably need elevated rights to do this aswell. You will have to sign in as the user.
Even if you manage to do this, don't. This is not what services is ment for and it is really bad practise. If you really want someting to pop up, have a seperate process instead.
It is popping up, but on the Window Station associated with the service.
I would suggest that you tweak your design such that your service doesn't need to interact in this manner. There are ways to get it to appear on an interactive desktop (you'd have to cope with issues such as impersonating the relevant user, targeting the correct desktop if nobody is logged on or if more than one person is logged on, etc.)
Just on a side note Windows services aren't built for interactivity. They are used to process behind-the-scenes type stuff. However, have you tried enabling the Interact with Desktop option on the service itself?