PDA

View Full Version : گفتگو: گرفتن آدرس جاری پروژه dll



arman_Delta2002
چهارشنبه 01 اسفند 1397, 16:29 عصر
با سلام
من با این تابع


private string DLLPath()
{
string dllPath = "";
if (System.Reflection.Assembly.GetEntryAssembly() != null)
{
dllPath = System.IO.Path.GetDirectoryName(System.Reflection. Assembly.GetEntryAssembly().Location.ToString());
}
else if (System.Reflection.Assembly.GetExecutingAssembly() != null)
{

dllPath = System.Reflection.Assembly.GetExecutingAssembly(). Location.ToString().Replace("\\DataAccessLayer.dll", "");
}
else
{
dllPath = Environment.CurrentDirectory.ToString();
}

if (dllPath == "")
{
return "\";
}

return "\";
}


در یک پروژه کلاس ای مسیر جاری dll رو بدست بیارم ولی زمانی که روی سرور هست این آدرس رو برمیگردونه !
C:\Windows\Microsoft.NET\Framewo-rk64\v4.0.30319\Temporary ASP.NET Files\root\40955516\1e06daaf\assembly\dl3\6e71a98a \f26c257b_62c7d401\
در صورتی که ادرس اصلی اینه
F:\project\Saham\

Mahmoud.Afrad
چهارشنبه 01 اسفند 1397, 22:30 عصر
خط 11 را به تنهایی اجرا و نتیجه را بررسی کنید.