473,320 Members | 1,921 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,320 software developers and data experts.

System.Reflection.Assembly.GetExecutingAssembly()

Has been trying to get an ASP.NET DLL's modification date/time for the
"release date/time" to be displayed on the page's footer

Using:
System.Reflection.Assembly
asm=System.Reflection.Assembly.GetExecutingAssembl y();
appVer = asm.GetName().Version.ToString();

// get the location of our executing assembly
System.IO.FileInfo inf = new System.IO.FileInfo(asm.Location);
DateTime dt = inf.LastWriteTime;
appDate = dt.ToString("d MMM yyyy")

log.Info ("asm.Location=" + asm.Location);
However, the debug log indicate that it is reading the last write time from
c:\winnt\microsoft.net\framework\v1.1.4322\tempora ry asp.net
files\MyProd\0bb3e1a5\e740ffe2\assembly\dl2\a5a617 54\024e623d_c70bc601\MyCompany.MyDept.MyProd.dll and not c\inetpub\wwwroot\MyProd\bin\MyProd.dll

How can I update my code to read the last modification date/time of where
the DLL was deployed?

Note the
1) Problem happens both on IIS5.1 / Win XP Pro SP2 and IIS6 / Windows 2003
server
2) .Net framework 1.1
3) Impersonation is used, impersonating the logged on user (no admin
priviledges)

Dec 28 '05 #1
1 17737
Hi,

welcome to MSDN newsgroup.
As for the getting assembly path problem, it is the expected behavior
because:

1. ASP.NET application will always shadow copy all the private
assemblies(in bin dir) to the temporary ASPNET folder......

2. And the Assembly.Location point to the assembly's location after it has
been shadow copied.....

For your scenario, you want to get the assembly's original file path (in
the application's private bin dir), I think you can consider:

1. Using the Assembly.CodeBase instead of the Assembly.Location , CodeBase
point to the original path before shadow copied. here is the MSDN document
on this:
=============
The location of the loaded file that contains the manifest. If the loaded
file was shadow-copied, the location is that of the file after being
shadow-copied. If the assembly is loaded from a byte array, such as when
using the Load(Byte[]) method overload, the value returned is an empty
string ("").
Remarks
To get the location before the file has been shadow-copied, use the
CodeBase property
=============

2. Also, if the assembly's file name is fixed, we can using the
Server.MapPath("~/bin") to get the private bin dir's file path and
concatenate with the assembly file name to get the full file path.....

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| Thread-Topic: System.Reflection.Assembly.GetExecutingAssembly()
| thread-index: AcYLyHaN2xw0eoxTSY2durKc+OoAjw==
| X-WBNR-Posting-Host: 198.240.128.75
| From: "=?Utf-8?B?UGF0cmljaw==?=" <qu*******@newsgroup.nospam>
| Subject: System.Reflection.Assembly.GetExecutingAssembly()
| Date: Wed, 28 Dec 2005 08:05:03 -0800
| Lines: 30
| Message-ID: <25**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.general
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.general:185171
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| Has been trying to get an ASP.NET DLL's modification date/time for the
| "release date/time" to be displayed on the page's footer
|
| Using:
| System.Reflection.Assembly
| asm=System.Reflection.Assembly.GetExecutingAssembl y();
| appVer = asm.GetName().Version.ToString();
|
| // get the location of our executing assembly
| System.IO.FileInfo inf = new System.IO.FileInfo(asm.Location);
| DateTime dt = inf.LastWriteTime;
| appDate = dt.ToString("d MMM yyyy")
|
| log.Info ("asm.Location=" + asm.Location);
|
|
| However, the debug log indicate that it is reading the last write time
from
| c:\winnt\microsoft.net\framework\v1.1.4322\tempora ry asp.net
|
files\MyProd\0bb3e1a5\e740ffe2\assembly\dl2\a5a617 54\024e623d_c70bc601\MyCom
pany.MyDept.MyProd.dll and not c\inetpub\wwwroot\MyProd\bin\MyProd.dll
|
| How can I update my code to read the last modification date/time of where
| the DLL was deployed?
|
| Note the
| 1) Problem happens both on IIS5.1 / Win XP Pro SP2 and IIS6 / Windows
2003
| server
| 2) .Net framework 1.1
| 3) Impersonation is used, impersonating the logged on user (no admin
| priviledges)
|
|

Dec 29 '05 #2

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

Similar topics

4
by: Jesse Elve | last post by:
I am using an XmlValidatingReader which uses an XSD for xml validation. The code has been performing reliably for months. Yesterday it failed for the first time with the following exception: ...
3
by: Bisbal | last post by:
Hi, I'd like to know if it is possible to create a form type from a string. My case: I have a DataTable with forms names (i.e frm_001_UserInfo.cs), and I'd like to create an instance of that...
6
by: JV | last post by:
Is there a way to determine that an assembly is running under an ASP.NET web application as opposed to a Windows application? For example, in an ASP.NET application if I call...
1
by: Brian | last post by:
I've looked through the previous posts on this one and have verified permissions and location of my Dlls, but I am still getting an exception when I try to Load an assembly. The directory where...
0
by: MWells | last post by:
I have a simple VS.NET solution with Project "A" as a web app and Project "B" as a class library. "B" does some HTML rendering, and uses reflection to locate and load the necessary rendering...
28
by: Nina | last post by:
I need to generate unique id for my application. Use system time to create id, which is the best fit, but I don't know how to do it. Please help. Thanks in advance for any input.
2
by: Greg Bell | last post by:
Hi why does first bit work and 2nd doesn't: 1. Dim m_Trademark As SR.AssemblyTrademarkAttribute m_Trademark = m_AssInfo.GetCustomAttributes(GetType(SR.AssemblyTrademarkAttribute), False)(0)...
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
10
by: Ron | last post by:
I have a situation where I have an object name as a string, and a method as a string. I need to construct a click handler with those two bits of information. This is what I came up with so far......
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.