473,586 Members | 2,555 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I disable shadow copying for my assembly?

I have a component that needs to access files which exist in the same
directory as the DLL containing the component itself. To determine the
component's installation directory, I'm using
System.Reflecti on.Assembly.Get ExecutingAssemb ly().Location. This worked fine
on my computer, but for another user, it failed because the assembly was
being loaded using a shadow copy of the DLL located in a different directory.
Is there a way, programmaticall y, to determine the location of the original
DLL, or is there a way to turn off shadow copying?

Thanks,
Bill
Aug 10 '05 #1
5 7408
You could try:

AppDomain.Curre ntDomain.BaseDi rectory

I'm not sure if this will work though as I have never tired it.

--
Brian Delahunty
Ireland

http://briandela.com/blog
"Bill Rust" wrote:
I have a component that needs to access files which exist in the same
directory as the DLL containing the component itself. To determine the
component's installation directory, I'm using
System.Reflecti on.Assembly.Get ExecutingAssemb ly().Location. This worked fine
on my computer, but for another user, it failed because the assembly was
being loaded using a shadow copy of the DLL located in a different directory.
Is there a way, programmaticall y, to determine the location of the original
DLL, or is there a way to turn off shadow copying?

Thanks,
Bill

Aug 10 '05 #2
Hi Bill,

Thanks for your post.

Based on my understanding, your assembly DLL access files relative to its
directory. However, if the user loads your assembly DLL with shadow copy
feature, because the files will not be copied to the cache directory, the
assembly can not find the files any more. If I misunderstand you, please
feel free to tell me.

Normally, we use AppDomainSetup to set the shadow copy function for our
AppDomain. In our appdomain, all the shadow copy process has been over, so
it is impossible to disable it now. However, we can use
AppDomain.Curre ntDomain.SetupI nformation property to get the AppDomainSetup
reference, then we can use AppDomainSetup. ShadowCopyDirec tories to get the
directory names our assembly original reside. Also, we can use
AppDomainSetup. CachePath property to get the cached shadow copy directory.

Hope this helps.
=============== =============== =============== =======
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Aug 11 '05 #3
Hi Bill,

Does my reply make sense to you? If you still have any concern, please feel
free to tell me. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Aug 16 '05 #4
Hi Jeffrey,

Your reply makes sense, but I'm not sure it solves my problem because it
just tells me which directories are being shadow copied, but it doesn't tell
me which directory my component came from. At any rate, a co-worker informed
me of a different solution which appears to work. Rather than calling
System.Reflecti on.Assembly.Get ExecutingAssemb ly().Location, I call
System.Reflecti on.Assembly.Get ExecutingAssemb ly().CodeBase which gives me the
install directory.

Thanks,
Bill

""Jeffrey Tan[MSFT]"" wrote:
Hi Bill,

Does my reply make sense to you? If you still have any concern, please feel
free to tell me. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Aug 16 '05 #5
Hi Bill,

Thanks for your feedback.

Yes, System.Reflecti on.Assembly.Get ExecutingAssemb ly().CodeBase should meet
your need, it will return the original assembly location.

However, I think the solution I provided in the last reply should also get
what you want. Once we have used AppDomainSetup. ShadowCopyDirec tories to
get where the assembly is shadown copied from, we can just add the assembly
dll name to this directory to get its original location, this should be the
same as what System.Reflecti on.Assembly.Get ExecutingAssemb ly().CodeBase
returns.

Because Asp.net used shadow copy technology, we can do the test in an
Asp.net application. I print out the different path with the code snippet
below:
private void Page_Load(objec t sender, System.EventArg s e)
{
this.Response.W rite(AppDomain. CurrentDomain.B aseDirectory+"< br>");

this.Response.W rite(AppDomain. CurrentDomain.S hadowCopyFiles. ToString()+"<br >
");

this.Response.W rite(AppDomain. CurrentDomain.S etupInformation .CachePath.ToSt r
ing()+"<br>");

this.Response.W rite(AppDomain. CurrentDomain.S etupInformation .ShadowCopyDire c
tories.ToString ()+"<br>");

this.Response.W rite(System.Ref lection.Assembl y.GetExecutingA ssembly().CodeB a
se+"<br>");
// Put user code to initialize the page here
}
On my machine, the output is:

c:/inetpub/wwwroot/webapp/shadowcopytest/
True
C:\WINDOWS\Micr osoft.NET\Frame work\v1.1.4322\ Temporary ASP.NET
Files\webapp_sh adowcopytest\7a 027e7d
c:\inetpub\wwwr oot\webapp\shad owcopytest\bin
file:///c:/inetpub/wwwroot/webapp/shadowcopytest/bin/shadowcopytest. DLL

As we can see, we can add
AppDomain.Curre ntDomain.SetupI nformation.Shad owCopyDirectori es with the dll
file name to get the original assembly location full path.

Hope this clarify my point.
=============== =============== =============== ==========
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Aug 16 '05 #6

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

Similar topics

0
2394
by: Mr 071 | last post by:
I am trying to use shadow copying provided by the framework, but I am not able to get it to work. More specifically, after a new app domain is created and the assembly loaded in it, it is still not possible to replace the original DLL although it has been shadow copied to the cache folder. I need to be able to replace plug-in DLLs while the...
4
4197
by: Barry Kelly | last post by:
I'm designing an application framework which will, amongst other things, live in an assembly hosted in the ASP.NET worker process, servicing webservice requests. Here's the scenario: APPFX is our application framework assembly. It has no life of its own - it's designed to provide components that are glued together by another, main...
0
1726
by: Damien Anselmi | last post by:
I am using the CompileAssemblyFromSource method of an ICodeCompiler instance to dynamically compile an assembly used by a Web Application. The assembly may be recompiled any number of times during a day as a user changes the underlying code. Each time the assembly is compiled it's version is updated e.g. from 1.0.0.1 to 1.0.0.2 and so on. ...
5
337
by: Bill Rust | last post by:
I have a component that needs to access files which exist in the same directory as the DLL containing the component itself. To determine the component's installation directory, I'm using System.Reflection.Assembly.GetExecutingAssembly().Location. This worked fine on my computer, but for another user, it failed because the assembly was being...
2
2682
by: Oenone | last post by:
I have an application which loads plugin DLLs from various directories on the local disk. To avoid problems with the DLLs being locked by IIS, I have modified my code so that it copies the DLLs to the /bin/ directory if it determines that they are newer than the version already there, and loads the copy. This then takes advantage of Shadow...
0
1717
by: Patrick F | last post by:
I keep getting this error message and i don't know whats the problem is and how to solve it. I have a webproject with 2 components (dll) added to it. One is called PhotoGallery and one is called Photo. Any suggestions on how to solve this? i can't do much at the moment. Server Error in '/PhotoGallery' Application....
1
8916
by: Patrick F | last post by:
I keep getting this error message and i don't know whats the problem is and how to solve it. I have a webproject with 2 components (dll) added to it. One is called PhotoGallery and one is called Photo. Any suggestions on how to solve this? i can't do much at the moment. Server Error in '/PhotoGallery' Application....
5
3908
by: mark_overstreet | last post by:
I have a generic data layer DLL that expects to read its connection string from it's own config file. The dll and config file have been placed in the bin directory (VS.NET2005). However, due to shadow copying, the config file does not get placed in the same directory as the executing assembly at execution time. For example, my data access...
0
1345
by: Mark | last post by:
I have a generic data layer DLL that expects to read its connection string from it's own config file located in the same directory (works great for winforms apps). The dll and config file have been placed in the bin directory (VS.NET2005). However, due to shadow copying, the config file does not get placed in the same directory as the...
0
7839
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...
0
8202
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. ...
1
5710
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...
0
5390
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...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
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
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
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...

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.