Window Service not triggering Functions in the Class Library (VB.NET)

Posted on 2006-11-20
Last Modified: 2008-01-16
This is a VB.NET project using VS2003 and 1.1 .NET framework.

I have a solution consists of 2 projects.
1) Email_Lib - which is a class library which consists of all the necessary functions.
2) Email_Services - a window service project that will start the email functions in the Email_Lib when the window is started.

In the Email_Services project, I add reference to the Email_Lib for the reasons that I need to use the functions in the Email_Lib, which is in my local development directory. I installed the Email_Services directly from the development directory, and when the services is started, the services starts the email functions that my application supposed to perform.

However, when I deploy the application and installed into my C: drive, when the service is started, nothing is done.

So, I tried to manually uninstall the service, and installed again from the development directory, and it works fine.

Could anyone enlighten me why is it so?? or any possible explaination??

Any reply is greatly appreciated!!
Question by:jescho
  • 4
  • 3
  • 2

Expert Comment

ID: 17985416
how are you installing the services?

Author Comment

ID: 17985445
I use the command :installutil email_services.exe  in the command prompt.


Assisted Solution

havascolino earned 200 total points
ID: 17986231
Dear Sir,

I think you problem to be a very simple one.
1. As you work in your dev librery you use refrences to the project you are working on. Email_lib and every thing is hanky dory.
2. When you deploy your refrence is lost to the Emai_lib.

Your should strongly sign your Email_Lib . Then install in the GAC by draging it to the c:\windows\assembly psedo directoy. Then remove the old reference create a reference to the sign assembly. Look at the properties of the referenced assembly (Email_Lib) in the Copy local  property It will be false. The assembly will not be copied localy but rather use the GAC to locat your assembly. reComplie the service . It should work now.

Hope this helps.

Author Comment

ID: 17991709
Hi havascolino,

thank you for your reply.

However, i dont quite understand what you mean by strongly sign the Email_lib? Do you mean manually drag the lib file to the c:\windows\assembly ? Currently, the CopyLocal property is "True", so I dont quite understand why it is false as u said?

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!


Assisted Solution

el_hey earned 300 total points
ID: 17993416

Try to create a strong name key for your library and add it to your configuration file.

1.  Use you Visual Studio 2003 Command Prompt on your Tools Folder
2.  Use sn-k to create a strong name key
3.  Add the key to your configuration

Next, Install it on your Global Assembly Cache

1.  Use Gacutil /i to install your assembly on the GAC

Rebuild your solution and then install your service again.


Author Comment

ID: 17994454
Hi el_hey,

I had tried the way you have mentioned, however, the result is the same. The Email_Services only did the job when it is being installed from the development directory.

The way I did:

1) I found the sn.exe in the VS2003 directory. Enter "sn -k emailkey.snk" in the command prompt to create the strong key file "emailkey.snk"
2) Then I include "<Assembly: AssemblyKeyFile("C:\MyPath\emailkey.snk")>" inside the "AssemblyInfo.vb" under Email_Lib project
3) Compile the Email_Lib project
4) Then I found the gacutil in the VS2003 directory
5) I copy the gacutil.exe to the Email_Lib.dll directory, execute the installation by enter "gacutil /i Email_Lib.dll" in the command prompt
6) Then, I rebuild the Email_Services and Email_Lib respectively
7) Install the service from the installed directory "C:ProgramFiles/Email/"

However, nothing happened.

And I try to uninstall the service, and installed in the development directory, nothing happened too.

Did I miss out anything when trying to create the strong key or anything that I did not include in the steps??

Accepted Solution

el_hey earned 300 total points
ID: 18000597

Hi Jescho,

You have done great on your installation, however, have you tried debugging your program?


Normally what I do is include a healthy amount of event log messages (via
theServiceBase.EventLog property ) especially in any asynchronous events
that may be raised within the service. Plus I will include Debug.Write &
Trace.Write in strategic locations.

Since you have installed it correctly, and you're sure the the service is started then we may conclude that there is an error raising somewhere in the program.

Try to debug it and post the ouput here.



Assisted Solution

havascolino earned 200 total points
ID: 18001489
Dear Sir,

The only thing you might have forgoten is to re-refrence the emailLib from the Service and make sure the copy local is false.

If you used X-copy install (Copied all your dll into one directory) this might not not be the problem but the strong signing is importent when going to production enviorment because other assemblies which are signed will have problem calling unsafe assemblies which are not sighed.

I agree with el_hey that the simplest way is to try catch the call from the service to the emailLib.dll and enter the error into the event log. This way you would have a better picture of your problem.
You may see that part of your dev enviorment was not installed on the prod server.
enforcing the ethernal programmer saying "It works on my station!!!";-)


Author Comment

ID: 18025464

I have found the reason for the problem.

The reason is.. i have 2 projects referenced to the same assembly. After I installed the program in programFiles directory, the 2 projects output reside with the assembly in the same directory.

So, when the Email_Lib is being accessed by Email_Services, another project, say Email_Client also trying to access Email_Lib, it is not possible due to the reason that Email_Services is accessing the Email_Lib.

So, for the time being, I workaround by having the 2 projects in different folders and copy the Email_Lib file to each of the directory, and it work fine!! =)

I don't know if having the assembly signed will help my situation, however, the above comments assist me on the debugging process.

Thanks alot guys~

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
countPairs challenge 7 58
strDist challenge 35 84
groovy example issue 10 70
Currency Conversion? 1 39
This article will show, step by step, how to integrate R code into a R Sweave document
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now