Visual Basic Development Bookmark and Share   
 Home > Visual Basic IDE > Uneffective changes
 

Uneffective changes

I'm developing a Windows Service, but for some reason, the changes I'm making to my code file aren't taking effect. I clean, build, and rebuild the solution as well as all the files that I'm changing, but nothing's happening.

Is this a problem with the installation of the service, or something wrong with my IDE? I just now thought that maybe I shouldn't be rebuilding the files...

Help is urgently needed and will be greatly appreciated.
Logan Young, MCPD Web Developer hopeful
LoganY  Monday, October 26, 2009 8:58 AM
Logan,

What kind of project you use to create service and where the change should be seen? Do you need to re-deploy your service?

Yang
yangxiao_MSFT  Tuesday, October 27, 2009 5:17 AM
Hi Yang,

I use the Windows Service project type from the New Project dialog under Visual Basic >> Windows to create the service.
I've written it so that the service creates a text file when it starts. The text file is where I'm having the service log it's activity.

I know my changes aren't taking effect because I've changed the text the service writes to this file when it starts (as well as the absolute path to the file), and there's no new file.

Before the changes, it was writing to C:\DMCS57Export\Service\log.txt
After the changes, it should write to C:\Temp\DMC S57 Export Service\log\eventlog.txt

The new file in C:\Temp isn't being created, and the new text that it should be writing isn't being written to the first txt file listed above.

The only way I know to make changes take effect as far as creating services goes is to re-deploy the service (since hitting F5 in VS isn't an option with services as they need to be installed from the VS command line using installutil)
Logan Young, MCPD Web Developer hopeful
LoganY  Tuesday, October 27, 2009 9:20 AM
Hi Logan,

I tried write to files in different harddisk locations in a simple Windows Service and it works. Can you following these instructions and let me know what happens?

1. Makesure the new folder exists (new file can be created but not new folder)
2. Stop the old service (in VS command prompt: sc stop yourServiceName)
3. Uninstall the old service (in VS Command prompt: installUtil /u yourServiceProjectName.exe
4. Make changes to old service -> new service, and build to generate new exe.
5. install the new service (in VS Command prompt: installUtilyourServiceProjectName.exe
6. Start the new service (in VS command prompt: sc start yourServiceName)

Thanks,
Yang
yangxiao_MSFT  Monday, November 02, 2009 11:39 PM
Hi Yang,

No luck. The directory exists, but when I start the service, it doesn't write to the text file (the code is below):

    Protected Overrides Sub OnStart(ByVal args() As String)
        My.Computer.FileSystem.WriteAllText("C:\Temp\DMCS57ExportService\log\eventlog.txt", _
            "[" & Now.ToLocalTime & "] Service started" & vbCrLf, True)

        Try
            If Now.TimeOfDay.ToString = StartTime Then
                ProcessExport()
            Else
                Dim CallBack As New TimerCallback(AddressOf ServiceTimerTick)
                ServiceTimer = New System.Threading.Timer(CallBack, Nothing, 0, 60000)
                ServiceTimer.InitializeLifetimeService()
                My.Computer.FileSystem.WriteAllText("C:\Temp\DMCS57ExportService\log\eventlog.txt", _
                            "[" & Now.ToLocalTime & "] Application started out of time." & vbCrLf & _
                            "Timer Started..." & vbCrLf, True)
            End If
        Catch ex As Exception
            My.Computer.FileSystem.WriteAllText("C:\Temp\DMCS57ExportService\log\eventlog.txt", _
                            "[" & Now.ToLocalTime & "] An error was encountered while starting the service:" & vbCrLf & _
                            ex.ToString & vbCrLf, True)
            OnStop()
        End Try
    End Sub
Does everything look right there for the eventlog.txt? I'd use the actual EventLog object, but I can't get it to write to the correct log (It writes to the Application log rather than the dedicated log for the service).
Logan Young, MCPD Web Developer hopeful
LoganY  Tuesday, November 03, 2009 8:35 AM
Hi Logan,

Can you check your project, after you build project, it shows successful in output window and also the .exe has been updated with new timestamp?

Thanks,
Yang
yangxiao_MSFT  Wednesday, November 04, 2009 2:14 AM
Hi Yang,

Here's the complete output of the build, copied directly from the output window:

------ Build started: Project: FTP, Configuration: Release Any CPU ------
FTP -> C:\DMCS57Export\Service\DMCS57ExportService\FTP\bin\Release\FTP.dll
------ Build started: Project: DMCS57ExportService, Configuration: Release Any CPU ------
DMCS57ExportService -> C:\DMCS57Export\Service\DMCS57ExportService\DMCS57ExportService\bin\Release\DMCS57ExportService.exe
========== Build: 2 succeeded or up-to-date, 0 failed, 0 skipped ==========

No timestamp, but it says 2 succeeded (That's the actual service and the FTP module).


Logan Young, MCPD Web Developer hopeful
LoganY  Wednesday, November 04, 2009 6:34 AM

Hi Logan,

I tried part of your code and it does take effect. Let's try this:

1) Comment out other parts of your code. Leave only the following statement in OnStart method.

My.Computer.FileSystem.WriteAllText("C:\Temp\DMCS57ExportService\log\eventlog.txt", _
"[" & Now.ToLocalTime & "] Service started" & vbCrLf, True)

2) rebuild project, make sure it's successful. Go to project folder, check to make sure .exe file has been updated with the right timestamp.
3) stop the existing service (sc stop ServiceName you can watch service state from control panel->administration tools->component services)
4) uninstall service (installUtil /u projName.exe)
5) re-install service (installUtil projName.exe)
6) re-start service (sc start ServiceName)

You should be able to see eventlog.txt gets generated under C:\Temp\DMCS57ExportService\log, if the directory exists.

Let me know if you can get this part working.

Yang

yangxiao_MSFT  Thursday, November 05, 2009 1:58 AM
Hi Yang,

The .exe isn't updating. After commenting everything but the code you pasted above in my OnStart method, I built the project, then the solution. Once VS reported "Build Succeeded", I went to the bin\Degub dir and checked the Date Modified. It's still saying 10/14/2009 1:53 PM
Logan Young, MCPD Web Developer hopeful
LoganY  Thursday, November 05, 2009 12:53 PM
Hi Logan,

I think we're getting closer to the issue. Since I can't repro this issue on my end, I'll need some help from you.

1) Can you try to create a new Windows service and paste only this piece of code to see if new .exe can be generated. Further, if you make change to the project and rebuild, if new .exe can be generated.

2) Can you let me know your machine configuration where you see the problem, including:
64 bits or 32 bits, OS version and language,where did you download beta2. Also please save your project in case I'll need it for repro.

Thanks!
Yang

yangxiao_MSFT  Thursday, November 05, 2009 7:34 PM
Hi Yang,

I'll post the results of the rebuild and the new project when I've done that, but for now, here's my system config:

Microsoft Windows XP
Professional
Version 2002
Service Pack 2
32 bit

AMD Sempron 2400+
1.66GHz, 1.18 GB of RAM

Language: English

I'm not using VS 2010 (I wish I was), I'm using VS 2005 still. Not sure about how to save the project in case you'll need it... I can archive it and email you the zip though.

Thanks for the help so far!
Logan
Logan Young, MCPD Web Developer hopeful
LoganY  Friday, November 06, 2009 6:41 AM
Thanks Logan for providing your configuration. Let me know if it works when you create a new project.
yangxiao_MSFT  Saturday, November 07, 2009 12:49 AM

You can use google to search for other answers

Custom Search

More Threads

• disappearing listmembers dropdown
• Problem with debugging - Declarations fails to initialize after Application.Restart
• Publish - Won't copy database on setup
• Unhandled Exception, Published Project Unable to Locate File.
• DatagridView query
• how can i contol in databse
• [OTP]NEW to VB, Simple REFRESH Script... HELP PLEASE!!!!
• Add Event Handler to VB CodeClass?
• IntelliSense for everything in VB ?
• Error- Could not load file or assembly