473,805 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
+ 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(AddressO f StartApplicatio n)
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", MessageBoxButto ns.YesNo, MessageBoxIcon. Information) = DialogResult.Ye s Then
t.Abort()
t = Nothing

UpdateApplicati on()
StartApplicatio n()

End If

End If

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

End Try
End Sub
Private Shared Sub StartApplicatio n()
Dim frm As New TestingForm.For m1
Application.Run (frm)

End Sub

--
--Eric Cathell, MCSA
Nov 21 '05 #1
5 2035
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(AddressO f StartApplicatio n)
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", MessageBoxButto ns.YesNo, MessageBoxIcon. Information) = DialogResult.Ye s Then
t.Abort()
t = Nothing

UpdateApplicati on()
StartApplicatio n()

End If

End If

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

End Try
End Sub
Private Shared Sub StartApplicatio n()
Dim frm As New TestingForm.For m1
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 ApplicationUpda terManager =
ApplicationUpda terManager.GetU pdater()

' Dim manifests As Manifest() = Nothing
' manifests = updater.CheckFo rUpdates()
' If manifests.Lengt h > 0 Then
' Return True
' Else
' Return False
' End If
' Catch ex As ThreadAbortExce ption
' ' Do nothing if the thread is being aborted, as we are explicitly
doing it
' Catch ex As Exception
' MessageBox.Show (ex.ToString, "Error", MessageBoxButto ns.OK,
MessageBoxIcon. Error)
' End Try

' End Function 'CheckAndUpdate

--
--Eric Cathell, MCSA
"Chris Dunaway" <du******@gmail .com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.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=noth ing) 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.mi crosoft.com> wrote in message
news:7F******** *************** ***********@mic rosoft.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(AddressO f StartApplicatio n)
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",
MessageBoxButto ns.YesNo, MessageBoxIcon. Information) = DialogResult.Ye s
Then
t.Abort()
t = Nothing

UpdateApplicati on()
StartApplicatio n()

End If

End If

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

End Try
End Sub
Private Shared Sub StartApplicatio n()
Dim frm As New TestingForm.For m1
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
4429
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++ program -- DSN710.SDSNSAMP(DSN8DLPL) to use for this purpose. I'm wondering if anyone out there has a COBOL equivalent to this as I do not have a C++ compiler?
5
1823
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 still use the UI components displayed earlier when i loaded the Assembly. How is this possible, it should not show up or throw some exception when i use the controls right? Please advice me how this behavior is possible even after i unloaded the...
1
2044
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 module with a newer version). How can I do that ? I used this code to load the module : // create instance for module
2
1606
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 directory and it looks like ASPNET runtime is holding on to the assemblies. Once i recycle the ASPNET process, i can delete this directory. Has this got anything to do with strong-named/signed assemblies ( even though deployed as private...
3
3657
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 allowing me to use frmMain.Load(). What can I use to load the main form, then unload the splash screen? Or should I, perhaps, load an invisible control form that first loads the splash screen, waits five seconds, then unloads it and loads the main...
0
1571
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 asp.Net application. Occasionaly, especially during peek CPU usage, the appDomain of the application gets unloaded by the w3wp.exe, and the background thread is terminated (we receive thread was being aborted exception). I guess the reason for...
1
1672
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 does all the ADO with it, but when check1.value = true its doing the ADO commands, but just not unloading, if anyone can shed some light would be most greatful. Kind Regards Devon. Module code. Option Explicit Public g_fmrSearch As...
0
1309
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 the task manager-"Applications" tab,i can detect it and prevent it from unloading,but if it is closed from the task manager-"Processes" tab,the form will be closed even without passing through the terminate,queryunload and unload events... I'm...
3
2409
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. I would like to see those changes appear in the listbox without unloading the form.
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10604
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10361
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7644
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6874
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5676
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3839
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3006
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.