473,473 Members | 2,169 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Unloading a DLL to update it.

I have done some searches on this and have found Herfrieds suggestions on opening the DLL in a different appDomain. I have not done this before and am curious on the consequences. Below is the code I am currently using, but it locks the dll.

<STAThread()> _
Public Shared Sub Main()
Try
Dim t As New Thread(AddressOf StartApplication)
t.Name = "DLLThread"
t.Start()
If CheckforUpdates() = True Then
' Prompt user if he wants to apply the updates
If MessageBox.Show("Updates are available for this program. Do you wish to install the updates?", "Updates Available", MessageBoxButtons.YesNo, MessageBoxIcon.Information) = DialogResult.Yes Then
t.Abort()
t = Nothing

UpdateApplication()
StartApplication()

End If

End If

Catch ex As Exception
MessageBox.Show(ex.ToString, "Exception Thrown")
Finally

End Try
End Sub
Private Shared Sub StartApplication()
Dim frm As New TestingForm.Form1
Application.Run(frm)

End Sub

--
--Eric Cathell, MCSA
Nov 21 '05 #1
5 2006
Eric,

pardon me but I'm not very clear on few things:

- Is your application loading/using this DLL as well or does it just
update/copy it?
- If your application is actually loading it, are you doing a dynamic load?

When you say it locks the dll, does that mean that you are not able to
update it? The reason i would understand is that you are not doing a clean
unload. If your application is loading the DLL, then use dynamic loading and
do a clean unload. i am doing an update (based on a windows event) it myself
in my Vb.net sample and didn't have any issues.

I can post some code on how do to that but I'm not really sure what I am
saying is relevant. Lemme know.

Regards,
Danny
"ECathell" wrote:
I have done some searches on this and have found Herfrieds suggestions on opening the DLL in a different appDomain. I have not done this before and am curious on the consequences. Below is the code I am currently using, but it locks the dll.

<STAThread()> _
Public Shared Sub Main()
Try
Dim t As New Thread(AddressOf StartApplication)
t.Name = "DLLThread"
t.Start()
If CheckforUpdates() = True Then
' Prompt user if he wants to apply the updates
If MessageBox.Show("Updates are available for this program. Do you wish to install the updates?", "Updates Available", MessageBoxButtons.YesNo, MessageBoxIcon.Information) = DialogResult.Yes Then
t.Abort()
t = Nothing

UpdateApplication()
StartApplication()

End If

End If

Catch ex As Exception
MessageBox.Show(ex.ToString, "Exception Thrown")
Finally

End Try
End Sub
Private Shared Sub StartApplication()
Dim frm As New TestingForm.Form1
Application.Run(frm)

End Sub

--
--Eric Cathell, MCSA

Nov 21 '05 #2
What does the CheckForUpdates method do?

Nov 21 '05 #3
While it is not relevant to the post and the question here is the code in
the checkforupdates

Private Shared Function CheckforUpdates() As Boolean

' Try
' ' Get the updater manager
' Dim updater As ApplicationUpdaterManager =
ApplicationUpdaterManager.GetUpdater()

' Dim manifests As Manifest() = Nothing
' manifests = updater.CheckForUpdates()
' If manifests.Length > 0 Then
' Return True
' Else
' Return False
' End If
' Catch ex As ThreadAbortException
' ' Do nothing if the thread is being aborted, as we are explicitly
doing it
' Catch ex As Exception
' MessageBox.Show(ex.ToString, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
' End Try

' End Function 'CheckAndUpdate

--
--Eric Cathell, MCSA
"Chris Dunaway" <du******@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
What does the CheckForUpdates method do?

Nov 21 '05 #4
Currently what I am doing is starting my application on a different thread,
checking for updates on the main thread, if there are updates then the
thread is stopped and the update is completed on the main thread. The
application is then restarted on the main thread. Since I am loading the dll
(which is actually the MDI interface for the application) it is locked from
being used. On more investigation yesterday, i found that even when it is no
longer used and disposed(t=nothing) it is still locked for use by the
windows application.

Looking over the other quickstarts I think I am going to try modifying the
No-Touch Deployment Quickstart,I think it has exactly what I am trying to do
in it...

--
--Eric Cathell, MCSA
"kurtcobain1978" <ku************@discussions.microsoft.com> wrote in message
news:7F**********************************@microsof t.com...
Eric,

pardon me but I'm not very clear on few things:

- Is your application loading/using this DLL as well or does it just
update/copy it?
- If your application is actually loading it, are you doing a dynamic
load?

When you say it locks the dll, does that mean that you are not able to
update it? The reason i would understand is that you are not doing a clean
unload. If your application is loading the DLL, then use dynamic loading
and
do a clean unload. i am doing an update (based on a windows event) it
myself
in my Vb.net sample and didn't have any issues.

I can post some code on how do to that but I'm not really sure what I am
saying is relevant. Lemme know.

Regards,
Danny
"ECathell" wrote:
I have done some searches on this and have found Herfrieds suggestions on
opening the DLL in a different appDomain. I have not done this before and
am curious on the consequences. Below is the code I am currently using,
but it locks the dll.

<STAThread()> _
Public Shared Sub Main()
Try
Dim t As New Thread(AddressOf StartApplication)
t.Name = "DLLThread"
t.Start()
If CheckforUpdates() = True Then
' Prompt user if he wants to apply the updates
If MessageBox.Show("Updates are available for this program. Do
you wish to install the updates?", "Updates Available",
MessageBoxButtons.YesNo, MessageBoxIcon.Information) = DialogResult.Yes
Then
t.Abort()
t = Nothing

UpdateApplication()
StartApplication()

End If

End If

Catch ex As Exception
MessageBox.Show(ex.ToString, "Exception Thrown")
Finally

End Try
End Sub
Private Shared Sub StartApplication()
Dim frm As New TestingForm.Form1
Application.Run(frm)

End Sub

--
--Eric Cathell, MCSA

Nov 21 '05 #5
I only asked because the code you posted does not seem to use an
AppDomain anywhere. I was wondering how you know if you need to
update? Do you load the assembly and check its version? Do you go by
the file date/time?

If you load the assembly to check it's version, then there is no way to
unload it unless you load it in a different AppDomain and I was
wondering if your CheckForUpdates method loaded the assembly in a
different AppDomain. Once the assembly is loaded, I think it will be
locked and that is blocking your attempt to update it.

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Rom Marshall | last post by:
Hi. Once a LOB size goes beyond 32KB in size, I'm not able to use the LOAD utility to unload the data off the tables for DB2 7.1 on OS/390. Instead, the documentation refers to a sample C++...
5
by: vineeth | last post by:
Hi I have GUI assembly which is loaded into a seprate Appdomain using AppDomain::Load method, after using it's function i unloaded the assembly by calling the AppDomain.UnLoad() method. But i can...
1
by: Microsoft | last post by:
Hi all, I have some application which dynamically loads a module as a DLL Assembly. Both are written in C#. I also would like to be able to dynamically unload this assembly (i.e. to update the...
2
by: Guru Prasad | last post by:
Is there a delay involved in unloading assemblies once a virtual directory is "deleted" using IIS Manager ? At times even after the virtual directory is removed i cannot delete the backing physical...
3
by: Eric A. Johnson | last post by:
In a new project I'm creating, I have my first form that loads being used as a splash screen, with a timer that activates after 5 seconds. I then want the main form to load. However, it isn't...
0
by: ibenc | last post by:
Is there a way to prevent w3wp.exe from unloading a particular appDomain. Some parameters, config files? Here is some info about why I need this. I have a long running background thread in...
1
devonknows
by: devonknows | last post by:
Ok, i posted about forcing a form to unload, now since ive implemented that, when check1.value = true, when you close the form, it doesnt unload, when check1.value = false, it unloads perfectly and...
0
vdraceil
by: vdraceil | last post by:
Hi,i use VB6.0..is it possible to prevent a form from unloading ever? I know to set cancel=true in query unload event of the form..but this applies only to limited cases. If my exe is closed from...
3
by: Kevin Woods | last post by:
The row source referes to a named area on an excel worksheet. The user form displays a list box using this row sources. From the user form changes are made to the named area on the excel worksheet....
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.