How can we help you today? How can we help you today?

Assembly.GetExecutingAssembly().Location is empty

I am embedding (not merging) an assembly into an .aspx project.
The following code:
Assembly currentAssembly = Assembly.GetExecutingAssembly();
var folder = Path.GetDirectoryName(currentAssembly.Location);
blows because Location is "".

What do I do to get the assembly location?

thanks

Matt
Matt::
0

Comments

3 comments

  • Alex D
    Embedded assemblies have no useful location to tell you. They aren't decompressed to a temporary location or anything, they are simply loaded from memory.
    Alex D
    0
  • Matt::
    yes, but it's 'host' assembly must have a location.
    Is there any way to get at that?
    Matt::
    0
  • simon.jackson
    Assembly.CodeBase is still set.

    string codeBase = assembly.CodeBase;
    string localPath = new Uri(codeBase).LocalPath;//NOTE: assembly.Location will often be "" because of {SA}

    I'm not sure if this behaviour is guaranteed in {SA}
    simon.jackson
    0

Add comment

Please sign in to leave a comment.