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

Retrieving path of executing assembly

SLE
Hi there,

We have a class method which is invoked through Remoting/IIS. Within this
class method, we need to get the physical path of the assembly (dll) in
which the method is executing. we have tried:

1) System.Reflection.Assembly.GetExecutingAssembly(). Location.ToString()
returns a temporary path, i.e.
c:\windows\microsoft.net\framework\v1.1.4322\tempo rary asp.net
files\cm.processing\2cff4017\312000e7\assembly\dl2 \e92f2bc0\ede223a1_c797c30
1\assembly.dll

2) System.IO.Path.GetFullPath(".")
returns c:\windows\system32\inetsrv
Any clues?

Thanks.
Nov 20 '05 #1
2 9168
There is nothing strange. The Assembly.Location returns where the assembly
was, and "." is the current path of the process. They are entirly different
things. Just like cmd.exe is installed in windows directory, but the
current path could be "c:\".

If you want the physical path of the dll, you might want the first one.

Nov 20 '05 #2
SLE
"Lifeng Lu" <no****@nospam.net> wrote...
There is nothing strange. The Assembly.Location returns where the assembly
was, and "." is the current path of the process. They are entirly different things. Just like cmd.exe is installed in windows directory, but the
current path could be "c:\".

If you want the physical path of the dll, you might want the first one.


Who said there is something strange? Fact is I need a way to get the
_original_ location within the code of an assembly and not the _actual_
location.

We have found the following (3th) way:

Dim assemblyPath As String =
System.IO.Path.GetDirectoryName(System.Reflection. Assembly.GetExecutingAssem
bly().CodeBase)

If assemblyPath.Substring(0, 6).ToLower() = "file:\" Then
assemblyPath = assemblyPath.Substring(6)
End If
.... which works fine.
--
SLE
Nov 20 '05 #3

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

Similar topics

7
by: Robert W. | last post by:
I think I'm going insane, but thought I'd check with you all first before I get myself commited! Here's a method I've built to retrieve an image: public static Image GetImage(string...
2
by: Rob | last post by:
What VB run-time methods are available to retrieve information (such as AssemblyCopyright, AssemblyProduct, AssemblyVersion, etc.) from the AssemblyInfo.vb file for the current executable? ...
4
by: Gary Townsend | last post by:
I am working on an auto update feature for my program and basically it gets the assembly information for the main application and compares that against the database the problem is that when i try...
4
by: Tim | last post by:
Hi, How can I find the path in which a dll is executing from? I do not want the Exe path. Is there a way to get the dll path in C# - something like the output of GetModuleFileName API ?
4
by: Huy Hoang | last post by:
I can retrieve the path of a Windows form using the Application object. However, if I write a class which will be compiled into a DLL, would it be possible to retrieve the DLL path (without passing...
2
by: Luis Arvayo | last post by:
I am compiling and executing c# code at runtime and I need to define in CompilerParameters.ReferencedAssemblies one of my own assemblies together with the standard System.dll u others. Example:...
5
by: Randy Smith | last post by:
Hi ALL, I wonder if anyone has been using n-tier to bind to a GridView control by using the ObjectDataSource. This is our first OOP web application, and we have no tables. Right now we are...
6
by: HONOREDANCESTOR | last post by:
Suppose I have a dll which might be installed in the directory c: \MyClass\. I want to be able to find the path of this dll from within the dll. In other words, I want a function that can return...
2
by: Berryl Hesh | last post by:
I want to access a development db at a known location (ie, "MyApp\MyData\MyDb.mdb") but an unknown machine. I've used "|DataDirectory|\MyDb.mdb" in app.config with some limited success before but...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
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...

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.