Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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.

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
If you don't know how to downgrade, my instructions below should be helpful.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

664 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