Assembly.GetExecutingAssembly().Location is empty

Early Access Program for SmartAssembly

Moderators: Luke Jefferson, JasonC, StephenC, Alex.Davies, melvyn.harbour, GrahamH, Simon C

Assembly.GetExecutingAssembly().Location is empty

Postby Matt:: » Mon Sep 20, 2010 11: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?

thanks

Matt
Matt::
 
Posts: 4
Joined: Mon Sep 20, 2010 11:31 am

Postby Alex.Davies » Thu Sep 23, 2010 11: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.
Alex
Developer,
Red Gate .NET Tools
Alex.Davies
 
Posts: 335
Joined: Tue Dec 02, 2008 12:23 pm
Location: Cambridge, uk

Postby Matt:: » Thu Sep 23, 2010 12:06 pm

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

Postby simon.jackson » Tue Nov 30, 2010 12:26 pm

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


Return to SmartAssembly EAP

Who is online

Users browsing this forum: No registered users and 0 guests