项目目录:
+ D:\mysolution\myproject1\ + D:\mysolution\myproject1\myproject.csproj
+ D:\mysolution\myproject1\bin\Debug\net6.0\myproject.exe
+ D:\mysolution\myproject1\bin\Debug\net6.0\myproject.dll
+ D:\mysolution\myproject1\bin\Debug\net6.0\myutils.dll
在myproject调用myutils中的函数,打印不同的程序路径,结果如下:
Directory.GetCurrentDirectory() | D:\mysolution\myproject1 |
Environment.CurrentDirectory | D:\mysolution\myproject1 |
AppContext.BaseDirectory | D:\mysolution\myproject1\bin\Debug\net6.0\ |
AppDomain.CurrentDomain.BaseDirectory | D:\mysolution\myproject1\bin\Debug\net6.0\ |
Environment.ProcessPath | D:\mysolution\myproject1\bin\Debug\net6.0\myproject.dll |
Process.GetCurrentProcess().MainModule.FileName | D:\mysolution\myproject1\bin\Debug\net6.0\myproject.dll |
Assembly.GetEntryAssembly().Location | D:\mysolution\myproject1\bin\Debug\net6.0\myproject.dll |
Assembly.GetCallingAssembly().Location | D:\mysolution\myproject1\bin\Debug\net6.0\myproject.dll |
Assembly.GetExecutingAssembly().Location | D:\mysolution\myproject1\bin\Debug\net6.0\myutils.dll |
Assembly.GetAssembly(typeof(MyTypeInMyUtils)).Location | D:\mysolution\myproject1\bin\Debug\net6.0\myutils.dll |
typeof(MyTypeInMyUtils).Assembly.Location | D:\mysolution\myproject1\bin\Debug\net6.0\myutils.dll |