- Recent
- Popular
- Tags (0)
- Subscribers (1)
- Self Installing Windows ServiceJanuary 4
-
Recently I had to initiate some background worker in a Windows Service. Writing a Windows Service with the built in .Net support is a no-brainer. The thing that caught me by surprise was that all the documentation states that I needed to add an installer for the service to run. After a little looking around, it turned out that it is not so difficult to create your own custom installer. I ended up writing a small class that can handle any service and thought I’d share it here.
The Windows Service part functions only as a bootstrapper for the real code that needs to run. I wanted to be able to run the code both in service mode and as a standard console application. So here is a dummy service with the installer. The dummy service just writes a single entry to the event log.
A few shortcuts:
I have hardcoded the logging for traceability, but in a real scenario you would probably want to inject a logger.
The library code is in the same assembly and namespace as the service. You would want to extract that out.The library code that needs to be run either in service or console mode looks like the following.
using System;
using System.Diagnostics;
using System.Threading;
namespace WindowsService1
{
public class Scheduler
{
private Timer _
- How to add words to an already loaded grammar using System.Speech and SAPI 5.3December 7 2008
-
I asked a question on StackOverflow about a week ago. Since I’ve gotten no response there, I thought that I’ll post it here. Maybe someone has a solution. Before I get to the question, a short detour. If you are building custom grammars with the System.Speech API here’s a neat little trick that I found when assembling some complex grammars. If you spell the words in your grammar more like they sound than how they’re really spelled, the recognition engine often gives me better results. Let’s say you want to recognize the word “pun”. If you spell it “punn” in the grammar, the recognition is better. In addition to calibrating the audio settings, some creative rewriting of some words increases the recognition confidence. Especially on short words.
Now to the question:
Given the following sample code,
Choices choices = new Choices();
choices.Add(new GrammarBuilder(new SemanticResultValue("product", "<product/>")));
GrammarBuilder builder = new GrammarBuilder();
builder.Append(new SemanticResultKey("options", choices.ToGrammarBuilder()));
Grammar g
- CodeRush Plugin – Navigate to Implementation Part 4December 3 2008
-
This is the last post in series on developing the navigate to an implementing method plugin. Here are links to the previous posts, part 1, part 2 and part 3.
Just to recap, the goal of the plugin is to be able to position the caret (what most people call the cursor), on a method call on an interface variable and navigate to specific implementations of the method.

In this post we’ll look at how we navigate to the correct method.
The call to navigate is made when the navigation provider (part of CodeRush) receives the navigation event.
private void navigationProvider1_Navigate(object sender,
- Beauty is in the eye of the beholderNovember 27 2008
-
In the last edition of Visual Studio Magazine, a reader-mail entry stated that he preferred VB.Net over C# because C# is ugly. Without entering that discussion, I find C# pretty at times. That reminded me of a an episode from high school. Our math teacher was ill and none of the regular replacement teachers were available. Instead we got a math professor from a university who stepped on late notice. I don’t remember much, but one thing got burnt into my memory. During that class she stood by the blackboard and scribbled something that at the time looked gibberish to me. For a few minutes she stood there with her back to the pupils. When she finally turned to us, she gazed towards us, back to the blackboard and then to us again. She said with a passionate voice: “Can you see the beauty?”
I couldn’t, and for years I didn’t even understand what can be beautiful in numbers or in source code.
This morning when the kids were still asleep I needed to compare two parse results and see if they differ.
private bool IdentifiersChanged(IEnumerable<ScopeIdentifier> parseResult)
{
if (_scopeIdentifiers == null)
return true;
var firstModification = parseResult
.Except(_scopeIdentifiers, new ScopeIdentifierComparer(
- Visual Studio Team System – Database Project won’t compileNovember 24 2008
-
We use Database Projects to keep multiple versions of our databases in sync (both schema and data). Lately I’ve encountered several annoying build errors. The cause for all of them seemed to be related to the fact that the validation database had gotten out of sync.
Partial error message (so that SE can pick it up): Error 7 TSD7031: An object with name already exists in the database project…
Solution:
- Close the database project.
- If the validation database is still present on the server, delete it. (The name of the database is ProjectName_GUID, where ProjectName is the name of the database project)
- Delete the ProjectName.dat file.
- Reopen the database project.
