GetExecutingAssembly().Location and DLL called by WebService

  • Thread starter Neil Macdonald [Intergraph]
  • Start date
N

Neil Macdonald [Intergraph]

I am attempting to load a file that is situated in the same directory as an assembly that is called via a webservice

string csfFilePath = System.Configuration.ConfigurationSettings.AppSettings["CSFFilePath"]
if(csfFilePath==null || csfFilePath.Length==0

csfFilePath=System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\"

_csfFilePath=csfFilePath

The first line using System.Configuration returns null; This I have found out is because only exe's can use the .config files

However the GetExecutingAssembly().Location return
@"c:\windows\microsoft.net\framework\v1.1.4322\temporary asp.net files\coordinatesystemtransformation\5e89ae88\c379ab0\assembly\dl2\df021851\907b49ab_fb49c401\

Which I guess is where the webservice is executing

Perhaps I am going about this all the wrong way; I am running in debug and need to step through the assembly and ws code to test

Any advice would be much help..
------------------------------------------------------------------------------------------------------------
Neil Macdonal
Senior Software Enginee
IntelliWhere Product Development Centr

Intergraph Corporation (NASDAQ: INGR
Intergraph Mapping and Geospatial Solution
Level 3, 299 Coronation Drive, Milton QLD Australia
 
M

[MSFT]

Hi Neil,

GetExecutingAssembly() is also not for a web service. It will return a
temporary folder for web service to load referenced assemblies. To Get the
phisical location of your asxm file, you may try following code in your web
service:

Context.Server.MapPath(".")

And its referenced assemblies should be in this sub "bin" folder.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
N

Neil Macdonald [Intergraph]

yep, this works @ run time. How does this work @ debug

my project structure is

\solution\webserviceprojec
\solution\assemblyprojec

files are built to \solution\build (this is common to both projects, but only the assembly delivers files to here

I need to step through both the webservice and the referenced assembly (currently as a project reference

------------------------------------------------------------------------------------------------------------
Neil Macdonal
Senior Software Enginee
IntelliWhere Product Development Centr

Intergraph Corporation (NASDAQ: INGR
Intergraph Mapping and Geospatial Solution
Level 3, 299 Coronation Drive, Milton QLD Australia
 
M

[MSFT]

Hi Neil,

Please feel free to correct me if I have misunderstood this. Based on my
understanding, you are working with a web serivce project, and its asmx
file should be in a virtual diretory, its assembly file (dll) should be in
a "bin" folder. However, from your description, they are in
"\solution\build". Can you explain more on this?

Regards,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
N

Neil Macdonald [Intergraph]

- I have one solution containing both the DLL/Assembly and the WebServic
- When I call GetExecutingAssembly() in the DLL it gives me the ASP.NET temp directory not the directory of where the dll i
- Both project outputs are set t \Solution\Buil
- I need to load an xml .config file in the DLL on initialization this currently is in the \build directory, along with the compiled project output (dll
- I want to be able to step through the code in both the webservice and DLL and return the right results

I am sure it is a simple solution

------------------------------------------------------------------------------------------------------------
Neil Macdonal
Senior Software Enginee
IntelliWhere Product Development Centr

Intergraph Corporation (NASDAQ: INGR
Intergraph Mapping and Geospatial Solution
Level 3, 299 Coronation Drive, Milton QLD Australia
 
M

[MSFT]

Hi Neil,

If you just want get the DLL's path, you may try following code in the
Class library:

System.Reflection.Assembly.GetAssembly( this.GetType() ).CodeBase.ToString()

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top