Overwriting .NET assemblies in use

F

Frank Rizzo

It seems that I can overwrite a .net assembly even though it is in use
(in most cases). In some cases, the OS says File in use. Is there a
write-up somewhere on when a .net assembly can be messed with (e.g.
overwritten, renamed, deleted, etc...).

Regards
 
W

Willy Denoyette [MVP]

Frank Rizzo said:
That's interesting (in fact I've often wondered why my asp.net assemblies run from folders
with cockamamie names). But in a winform app, the shadow folder functionality is not on,
however, I can still delete or rename the assembly when in use.

Are you sure "the" assembly is un use? My guess is that the loaded assembly, is not the one
you are deleting/overwriting.
Assemblies are just regular files opened by the OS in read-only mode, no-one can ever delete
or overwrite the file as long as there is still an open handle to the file.

Willy.
 
F

Frank Rizzo

Willy said:
Are you sure "the" assembly is un use? My guess is that the loaded
assembly, is not the one you are deleting/overwriting.
Assemblies are just regular files opened by the OS in read-only mode,
no-one can ever delete or overwrite the file as long as there is still
an open handle to the file.

Try this. Start a winform app. While it's running, try to rename the
exe. You will see that the OS will not complain about it.
 
K

Kevin Yu [MSFT]

Hi Frank,

It is impossible to write to the EXE of a running application (or any of
its DLLs, for that matter). However, it is possible to rename the EXE and
copy a new EXE with the original name in its place. The application will
continue to run from the renamed EXE, and you won't be able to delete the
renamed EXE until you exit.

It is common to all the .exes including a .NET application. Please check
the following link for more information.

http://groups.google.com/group/comp.os.ms-windows.programmer.win32/browse_th
read/thread/d4caf1f10b94f46/34a25255651c63ae?lnk=st&q=exe+rename+share+write
&rnum=9#34a25255651c63ae

Kevin Yu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
W

Willy Denoyette [MVP]

Frank Rizzo said:
Willy said:
Frank Rizzo said:
Peter Bromberg [C# MVP] wrote:
Frank,
This rather concise post by Junfeng Zhang should prove helpful:

http://blogs.msdn.com/junfeng/archive/2004/02/09/69919.aspx

That's interesting (in fact I've often wondered why my asp.net assemblies run from
folders with cockamamie names). But in a winform app, the shadow folder functionality
is not on, however, I can still delete or rename the assembly when in use.

Are you sure "the" assembly is un use? My guess is that the loaded assembly, is not the
one you are deleting/overwriting.
Assemblies are just regular files opened by the OS in read-only mode, no-one can ever
delete or overwrite the file as long as there is still an open handle to the file.

Try this. Start a winform app. While it's running, try to rename the exe. You will see
that the OS will not complain about it.

Who's talking about rename? Renaming a file does not result in a delete or overwrite of the
attached file (the exe), rename isn't even a file IO operation, it doesn't touch the file,
all it does is changing the name of the file in the MFT (NTFS).

Willy.
 
K

Kevin Yu [MSFT]

Hi Frank,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top