473,379 Members | 1,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

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.Reflection.Assembly.GetExecutingAssembly(). 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, programmatically, 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 7354
You could try:

AppDomain.CurrentDomain.BaseDirectory

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.Reflection.Assembly.GetExecutingAssembly(). 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, programmatically, 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.CurrentDomain.SetupInformation property to get the AppDomainSetup
reference, then we can use AppDomainSetup.ShadowCopyDirectories 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.Reflection.Assembly.GetExecutingAssembly(). Location, I call
System.Reflection.Assembly.GetExecutingAssembly(). 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.Reflection.Assembly.GetExecutingAssembly(). 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.ShadowCopyDirectories 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.Reflection.Assembly.GetExecutingAssembly(). 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(object sender, System.EventArgs e)
{
this.Response.Write(AppDomain.CurrentDomain.BaseDi rectory+"<br>");

this.Response.Write(AppDomain.CurrentDomain.Shadow CopyFiles.ToString()+"<br>
");

this.Response.Write(AppDomain.CurrentDomain.SetupI nformation.CachePath.ToStr
ing()+"<br>");

this.Response.Write(AppDomain.CurrentDomain.SetupI nformation.ShadowCopyDirec
tories.ToString()+"<br>");

this.Response.Write(System.Reflection.Assembly.Get ExecutingAssembly().CodeBa
se+"<br>");
// Put user code to initialize the page here
}
On my machine, the output is:

c:/inetpub/wwwroot/webapp/shadowcopytest/
True
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Tempo rary ASP.NET
Files\webapp_shadowcopytest\7a027e7d
c:\inetpub\wwwroot\webapp\shadowcopytest\bin
file:///c:/inetpub/wwwroot/webapp/shadowcopytest/bin/shadowcopytest.DLL

As we can see, we can add
AppDomain.CurrentDomain.SetupInformation.ShadowCop yDirectories 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
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...
4
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...
0
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...
5
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...
2
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...
0
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...
1
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...
5
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...
0
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.