Home All Groups Group Topic Archive Search About

problem with getting location of running assembly at runtime

Author
1 Aug 2006 3:24 PM
Omatase
I have an xslt file I need to open at runtime. Here is my
configuration:

main project (dll)
|-----xslt file
unit test project

I have a reference to my main project in my unit test project. Both
projects are in the same solution. I am trying to test a method that
transforms
some XML based on a stylesheet I have in the main project. The xslt
file's copy mode is set to copy always. The Build Action is set to
content.

When I debug the Unit Test to see what is happening it goes into the
main assemblie's method and tries to open the xslt file. The xslt file
is not getting copied to the output directory. It IS getting copied to
the bin directory (which is what I think it's supposed to be doing),
but for some reason the main assembly file that is being executed is
out in another temp directory. That directory has no xslt file in it
and when I try to dynamically derive the directory the only path I
receive back is the temp directory. This makes it impossible to find
and open my xslt file.

Can anyone tell me how this is supposed to be done under these
circumstances?

I have tried
Assembly.GetExecutingAssembly().Location
Assembly.GetExecutingAssembly().CodeBase
Assembly.GetCallingAssembly().Location
Assembly.GetCallingAssembly().CodeBase

they all return temp directories that don't have the file I'm looking
for copied into it.

AddThis Social Bookmark Button