在winform中的OnPaint事件中,AppDomain.CurrentDomain.BaseDirectory得到的是下面这个路径

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE

Application.ExecutablePath得到的是C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe

file:///C:/Users/clu/AppData/Local/Microsoft/VisualStudio/15.0_74da2886/ProjectAssemblies/us6sa4js01/Accor.Windows.Forms.dll

https://stackoverflow.com/questions/837488/how-can-i-get-the-applications-path-in-a-net-console-application

System.Reflection.Assembly.GetExecutingAssembly().Location1

Combine that with System.IO.Path.GetDirectoryName if all you want is the directory.

1As per Mr.Mindor's comment:
System.Reflection.Assembly.GetExecutingAssembly().Location
returns where the executing assembly is currently located, which may or
may not be where the assembly is located when not executing. In the
case of shadow copying assemblies, you will get a path in a temp
directory. System.Reflection.Assembly.GetExecutingAssembly().CodeBase will return the 'permanent' path of the assembly.

https://stackoverflow.com/a/841320/3782855

AppDomain.CurrentDomain.BaseDirectory

Don't use this. The BaseDirectory can be set at runtime. It is not guaranteed to be correct (like the accepted answer is).

entryAssembly.GetSatelliteAssembly

System.IO.FileNotFoundException: Could not find file 'file:///C:/Users/clu/AppData/Local/Microsoft/VisualStudio/15.0_74da2886/ProjectAssemblies/dgz79z6i01/en-US/Accor.Windows.Forms.resources.DLL'.
File name: 'file:///C:/Users/clu/AppData/Local/Microsoft/VisualStudio/15.0_74da2886/ProjectAssemblies/dgz79z6i01/en-US/Accor.Windows.Forms.resources.DLL'

AppDomain.CurrentDomain.BaseDirectory的更多相关文章

  1. C#中AppDomain.CurrentDomain.BaseDirectory及各种路径获取方法

    // 获取程序的基目录.System.AppDomain.CurrentDomain.BaseDirectory // 获取模块的完整路径,包含文件名System.Diagnostics.Proces ...

  2. 关于程序路径Path.Combine以及AppDomain.CurrentDomain.BaseDirectory

    关于程序路径 LucenePath:@(System.Configuration.ConfigurationManager.AppSettings["LucenePath"])&l ...

  3. C#中AppDomain.CurrentDomain.BaseDirectory与Application.StartupPath的区别

    // 获取程序的基目录. System.AppDomain.CurrentDomain.BaseDirectory // 获取模块的完整路径. System.Diagnostics.Process.G ...

  4. AppDomain.CurrentDomain.BaseDirectory是什么

    AppDomain.CurrentDomain.BaseDirectory 是获取基目录,它由程序集冲突解决程序用来探测程序集.由显示的路径可以看出,它代表的是程序集所在的目录,它具有读取和写入的属性 ...

  5. C# AppDomain.CurrentDomain.BaseDirectory

    AppDomain.CurrentDomain.BaseDirectory   是获取基目录,它由程序集冲突解决程序用来探测程序集.由显示的路径可以看出,它代表的是程序集所在的目录,它具有读取和写入的 ...

  6. AppDomain.CurrentDomain.BaseDirectory项目目录相关操作

    链接:https://www.cnblogs.com/guolianyu/p/3980971.html 经常用到,每次都百度,所以自己备份一下!

  7. .Net AppDomain.CurrentDomain.AppendPrivatePath(@"Libs");

    今天就说说.Net中通过反射取得某个类型时,我们怎么知道这个类型在硬盘上的哪个角落?比如说,假如我们需要要求服务端动态载入某个数据源,那服务端怎么知道数据源在哪?网上大部分的教程都写着,可以使用Ass ...

  8. AppDomain.CurrentDomain.GetAssemblies()

    AppDomain.CurrentDomain.GetAssemblies() ,获取已加载到此应用程序域的执行上下文中的程序集 解释地址 从微软的解释也可以得知,这个方法只能获取已经加载到此应用程序 ...

  9. AppDomain.CurrentDomain.AssemblyResolve

    AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); 参 ...

随机推荐

  1. Android无线测试之—UiAutomator UiSelector API介绍之二

    Android的布局与组件及组件属性介绍 一.布局: 1)线性布局:控价在线性方向上一次排列 2)表格布局:向表格一样有标准的行和列 3)相对布局:通过相对定位的方式让控件出现在布局的任何位置 4)帧 ...

  2. JQUERY实现的小巧简洁的无限级树形菜单

    JQUERY实现的小巧简洁的无限级树形菜单,可用于后台或前台侧栏菜单!兼容性也比较好. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Tra ...

  3. python学习【第十篇】单例设计模式

    单例设计模式 目的:让类创建对象,在系统中只有唯一的实例,让每一次创建的对象返回的内存地址都是相同的. __new__方法 使用类名创建对象时,python解释器首先会调用__new__方法为对象分配 ...

  4. poj2420(模拟退火大法好)

    // // main.cpp // poj2420 // // Created by 陈加寿 on 16/2/13. // Copyright © 2016年 chenhuan001. All rig ...

  5. 【BZOJ2282】[Sdoi2011]消防 树形DP+双指针法+单调队列

    [BZOJ2282][Sdoi2011]消防 Description 某个国家有n个城市,这n个城市中任意两个都连通且有唯一一条路径,每条连通两个城市的道路的长度为zi(zi<=1000). 这 ...

  6. outlook撤回已发送邮件

    官方教程参考: https://support.office.com/zh-cn/article/%E5%8F%91%E9%80%81%E9%82%AE%E4%BB%B6%E5%90%8E%E6%92 ...

  7. 【转】NPOI读写Excel

    1.整个Excel表格叫做工作表:WorkBook(工作薄),包含的叫页(工作表):Sheet:行:Row:单元格Cell. 2.NPOI是POI的C#版本,NPOI的行和列的index都是从0开始 ...

  8. 【python】-- Django Form

    Django  Form Django的Form主要具有一下几大功能: 生成HTML标签 验证用户数据(显示错误信息) HTML Form提交保留上次提交数据 初始化页面显示内容(自定义样式) 一.F ...

  9. RabbitMQ_消息队列基本使用_2

    简介 RabbitMQ:接受消息再传递消息,可以视为一个“邮局”. 发送者和接受者通过队列来进行交互,队列的大小可以视为无限的,多个发送者可以发生给一个队列,多个接收者也可以从一个队列中接受消息. p ...

  10. C语言运算符优先级误解

    优先级问题 表达式 可能误以为的结果 实际结果 .的优先级高于*. ->操作符用于消除这个问题 *p.f p所指对象的字段f. (*p).f 对p去f偏移,作为指针,然后进行解除引用操作. *( ...