Question

In vs2008 (C#):

I have :

  1. a main project (windows app)
  2. WCF Library
  3. WCF Host
  4. WCF Client (Windows app)

For testing my service with created client, I call my client form in my main proj and after getting the input requirement of service by this form, I start making response of service by calling my service contract method .

In this service I need to create a proper connection string with received parameter for request and I need my application startup path (D:\myProj.dll) to get access to an exe file. Unfortunately after using different kinds of codes that return this path, exactly at point of calling my service, I get another paths I don't need (myproj, bin\debug or c:\programfiles\visual studio9\common7\IDE)

Can you help me ?

For additional info I have to say that I added this path by a command to post-build event of my service library and client.

Please help me to get access to this path (startup path of my project -> D:\myProj.dll)

Thank you in advance

Was it helpful?

Solution

from MSDN

path = System.IO.Path.GetDirectoryName(
          System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);

to get the path of a DLL your code is using:

string fullPath = System.Reflection.Assembly.GetAssembly(typeof(MyClass)).Location;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top