Red Gate forums :: View topic - Assembly.GetExecutingAssembly().Location is empty
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SmartAssembly EAP
SmartAssembly EAP forum

Assembly.GetExecutingAssembly().Location is empty

Search in SmartAssembly EAP forum
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.
Jump to:  
Author Message
Matt::



Joined: 20 Sep 2010
Posts: 4

PostPosted: Mon Sep 20, 2010 11:33 am    Post subject: Assembly.GetExecutingAssembly().Location is empty Reply with quote

I am embedding (not merging) an assembly into an .aspx project.
The following code:
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
Back to top
View user's profile Send private message
Alex.Davies



Joined: 02 Dec 2008
Posts: 335
Location: Cambridge, uk

PostPosted: Thu Sep 23, 2010 11:20 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Matt::



Joined: 20 Sep 2010
Posts: 4

PostPosted: Thu Sep 23, 2010 12:06 pm    Post subject: Reply with quote

yes, but it's 'host' assembly must have a location.
Is there any way to get at that?
Back to top
View user's profile Send private message
simon.jackson



Joined: 08 Jan 2009
Posts: 45

PostPosted: Tue Nov 30, 2010 12:26 pm    Post subject: Reply with quote

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}
Back to top
View user's profile Send private message
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies. All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group