Assembly.GetExecutingAssembly().Location is empty

Early Access Program for SmartAssembly

Assembly.GetExecutingAssembly().Location is empty

Postby Matt:: » Mon Sep 20, 2010 10:33 am

I am embedding (not merging) an assembly into an .aspx project.
The following code:
Code: Select all
Assembly currentAssembly = Assembly.GetExecutingAssembly();
var folder = Path.GetDirectoryName(currentAssembly.Location);

blows because Location is "".

What do I do to get the assembly location?


Posts: 4
Joined: Mon Sep 20, 2010 10:31 am

Postby Alex.Davies » Thu Sep 23, 2010 10:20 am

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.
Red Gate .NET Tools
Posts: 335
Joined: Tue Dec 02, 2008 11:23 am
Location: Cambridge, uk

Postby Matt:: » Thu Sep 23, 2010 11:06 am

yes, but it's 'host' assembly must have a location.
Is there any way to get at that?
Posts: 4
Joined: Mon Sep 20, 2010 10:31 am

Postby simon.jackson » Tue Nov 30, 2010 11:26 am

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}
Posts: 45
Joined: Thu Jan 08, 2009 9:42 am

Return to SmartAssembly EAP

Who is online

Users browsing this forum: No registered users and 0 guests