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

Posted on 2006-11-20
Medium Priority
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 800 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.
7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.


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?


Assisted Solution

el_hey earned 1200 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 1200 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 800 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

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

In this post we will learn different types of Android Layout and some basics of an Android App.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Introduction to Processes
Starting up a Project

597 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