Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 427
  • Last Modified:

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

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!!
0
jescho
Asked:
jescho
  • 4
  • 3
  • 2
4 Solutions
 
el_heyCommented:
how are you installing the services?
0
 
jeschoAuthor Commented:
I use the command :installutil email_services.exe  in the command prompt.

0
 
havascolinoCommented:
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.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
jeschoAuthor Commented:
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?

0
 
el_heyCommented:

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.

cheers!
0
 
jeschoAuthor Commented:
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??
0
 
el_heyCommented:

Hi Jescho,

You have done great on your installation, however, have you tried debugging your program?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtskdebugginwindowsservice.asp

Specifically:
http://msdn.microsoft.com/library/d...pplications.asp

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.

Goodluck

0
 
havascolinoCommented:
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!!!";-)

0
 
jeschoAuthor Commented:
Hi,

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~
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now