[SOLVED] VB.NET Windows Service cannot start System.IO.FileNotFoundException

I was creating a Windows service that includes a dll file. Whenever I tried to include the dll, I get following error.

I checked through internet but none of them seemed to be helpful. The script couldn’t even enter into OnStart() function and I couldn’t even write any logs to check where the program is faulty. After some research, I checked the dll compiled version. I found that the dll was compiled in version .NET 2.0.50727. Then got some hint that the service was trying to find something on .NET 4 folder but the dll library was compiled in older version and need some reference. Then finally I found that by enabling v2 legacy activation policy, it could find and load the file easily. Here is what I did:

  • Open Solution Explorer for the project
  • Double-click and open App.config file
  • There you will find a tag something like this:
  • Replace it with:

There is it ready. Now your application will run like a charm. If this was the case for Windows Form application, you will directly be notified as System.IO.FileNotFoundException with a Visual Studio error stating something like

And then the application should run perfectly with the above simple replacement.

Leave a Reply

Your email address will not be published. Required fields are marked *