The NAS starts a codeunit that in its turn starts a .NET 1.1 component that listens to a port for incomming ip network messages from another computer. When that computer connects, a new thread is launched to handle communication, the main process keeps on listening.
When there is an error message in Navision, the NAS "restarts" (in the event viewer I see the database, company, startupparameter, etc.) but it seems that the .NET component is still running, keeping the connection with the other computer alive. The new instance of the .NET component sees that the log file it opens is allready in use and the port it wants to listen to is allready listened by the old process.
The codeunit is of course a singleinstance. I create a timer automation var in it, in the OnRun I check with NOT ISCLEAR if it is created, if so I do an exit, if isclear then I start the .NET component. So getting these errors, it seems that the codeunit has been "cleared" but the .NET component not. What can I do to make the .NET component close itself so it can free the log file and the listening to the port?
Thanks in advance,
Remco
0
Answers
"Timer::TimerError(ErrorString : Text[1024])".
And there I do the error handling.
If you send me your email address I will send you my codeunit.
email: dick@dasautomatisering.nl
www.dasautomatisering.nl
The NAS does not truly restart, but my codeunit is apparently "gone" (the timer object is cleared so there must be a new instance of the singleinstance codeunit) and is run again. The reason I thought of this morning is that a .NET object is not destroyed when its application environment still exists and although there are probably no references to it, it keeps on logging and listening. Maybe what you do in the timer::timererror is telling the .NET object to dispose itself?
where the 2nd parameter means
False is default, but you newer knows... #-o
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
The type of error my problem is about is in case of a locked table. If a user locks a table/record that the NAS process also wants to lock then, after the lock timeout, the singleinstance codeunit is completely gone. See the following screendump:
- 10:08:43: The Communicatie Interface table cannot be changed because it is locked by another user.
10:08:43:
10:08:43: Wait until the user is finished and then try again.
- 10:08:44: The Navision Application Server nav-sql recovered using the following configuration and is now fully operational.
10:08:44: Database Server Name = IND04\SQLEXPRESS
10:08:44: Database = Ontw20070102
10:08:44: Company = Ontw20070122
10:08:44: Startup Parameter = COMDEV
The .NET component stays in memory and keeps running, because nassql.exe does not stop. There are 2 ways to deal with this I think:
1) Let the .NET component write in the database (probably causing more locks!)
2) The .NET component has to free its resources (port and log file)
Option 2 is my favorite. I'll check out some .NET forums, maybe they can help. I'll let you know!
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I created the .NET component in codeunit X and did a "bad thing" in codeunit Y (both singleinstance). The result is the same, the NAS gets rid of both codeunits and recovers as mentioned above.
Next thing I'm going to try is to run the .NET component from a VB 6.0 ActiveX DLL. I made a small test COM component and the destructor fires when the NAS recovers, so there I could call a cleanup function in the .NET component and shut down the listening and close the log file.
To be continued....
PS : anyone experienced with a .NET component call in VB6? The existing .NET component I can add as a reference, but I cannot see the functions and properties when programming...
On this forum there are threads about creating Automations from VS2005 and what is needed to do to see the functions from NAV.
http://www.mibuso.com/forum/viewtopic.php?t=14377
http://www.mibuso.com/forum/viewtopic.p ... c&start=30
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
My status up till now: A VB6 component's destructor fires when the NAS is going down to recover. In the desctructor code I will tell the .NET comp to stop listening/logging. The .NET component will stay in memory, but harmless, the GC will cleanup sometime.
Keep u posted!
It took me a while because I had to abort some threads and they block on tcpListener.AcceptTcpClient() and NetworkStream.Read(). I had to use the tcpListener.Pending() and NetWorkStream.DataAvailable() functions before to get the threads to abort.