在MSI工程中,经常会遇到这样的情况:

MSI 工程需要调用DLL(C++)中的一个函数实现某些特殊或者复杂的功能,通常的做法是在Custom Action 中调用该DLL 。

那么在安装过程中,该Custom Action 被调用的时候,如何使用Visual Studio 逐行Debug DLL 的源代码呢?

答案是:使用VS2010 中的Attach to Process 就可以实现。

步骤如下:

1> VS 工程设置为Debug 模式,并设置断点。

在断点前,弹出一个 dialog ,用来标识debug的 开始位置。以 C++ DLL 获取 MSI Property 中的工程为例。

2> 以 Custom Action : dynamic link library 中的 MSI 工程为例。 编译MSI 工程,运行安装包。

3> 弹出设定的 dialog 时,在VS 工程中选择,Debug / Attach to Process…

Msiexec.exe 是windows installer 服务,选择运行MessageBox 的windows installer服务,点击 ”Attach” 。

在VS 工程中,将鼠标移到断点处,可以看到工程和 msiexec.exe 已经关联了起来。

4> 继续安装,在弹出的dialog 中 点击“OK”。

再看VS 工程,程序就停在了断点处,之后就可以逐行debug代码了。

5> 按下 F10,进入下一行代码,弹出如下对话框,会发现是乱码,原因待续。

补充一下:productName 参数接收的是 MSI 中 Property 表中的 ProductName 属性值。

详情请参见:Custom Action : dynamic link library

---------------------------------------------------------------------------------------

Debug 过程中,可能会发现 Debug 断点没有被执行到,红色断点变成了空心的黄色圆圈,将鼠标停放到断点上,相关的提示信息就会显示出来。

可能会遇到的问题:

1> The breakpoint will not currently be hit. No symbols have been loaded for this document.

解决方案:

1)工程右键 Property -> Configuration Properties -> Linker / Debugging / Generate Debug Info

设置为 : Yes (/DEBUG)

2)如果还不好用的话,试试下面的方法:

Tools -> Options... ->Debugging / Symbols

a>手动添加 .pdb 文件的路径

b>勾选 “Microsoft Symbol Servers”

2>

The breakpoint will not currently be hit. The source code is different from the original version.

To allow the breakpoint to be hit when the source code is different, right-click on the breakpoint, choose 'Location...', and turn on 'Allow the source code to be different from the original version.'

To allow this for all breakpoint, disable the option 'Require source files to exactly match the original version' under Tools, Options, Debugging, General.

这种情况原因很明显,就是你修改了源代码,但是没有重新编译,MSI 工程中引用的 DLL 的源代码和工程里的不一致,就出现了断点没有被执行到的情况。

按照提示的信息照做就可以了。

相关链接参考:

Debug a custom action dll

How to: Attach to a Running Process

Attach to Process in Visual Studio

How to debug Custom Action DLL的更多相关文章

  1. Custom Action : dynamic link library

    工具:VS2010, Installshield 2008 实现功能: 创建一个C++ win32 DLL的工程,MSI 工程需要调用这个DLL,并将Basic MSI工程中的两个参数,传递给DLL, ...

  2. Wix打包系列(三)自定义Action(Custom Action)

    原文:Wix打包系列(三)自定义Action(Custom Action) 3.1 关于Action 我们已经知道如何生成具有标准安装界面的安装程序了,Windows Installer按照我们的界面 ...

  3. WIX Custom Action (immediate, deffered, rollback)

    Following content is directly reprinted from From MSI to WiX, Part 19 - The Art of Custom Action, Pa ...

  4. SharePoint 2010/SharePoint 2013 Custom Action: 基于Site Collection 滚动文字的通知.

    应用场景: 有时候我们的站点需要在每个页面实现滚动文字的通知,怎么在不修改Master Page的情况下实现这个功能?我们可以使用Javascript 和 Custom Action 来实现. 创建一 ...

  5. Installshield: custom action return value

    参考:MSDN: Custom Action Return Values 参考:MSDN: Logging of Action Return Values

  6. Default Custom Action Locations and IDs

    Default Custom Action Locations and IDs SharePoint 2013                             The following ta ...

  7. SharePoint 2013 - User Custom Action

    1. User Custom Action包含Ribbon和ECB,以及Site Action菜单等,参考此处: 2. 系统默认ECB的Class为: ms-core-menu-box --> ...

  8. 错误 1 无法将程序集“NBear.Data.dll”复制到文件“D:\newbpm\bpm\SureBpm\Bin\NBear.Data.dll”。无法将“D:\newbpm\bpm\SureSoft.WebServiceBaseLib\bin\Debug\NBear.Data.dll”添加到网站。 无法添加文件“Bin\NBear.Data.dll”。 拒绝访问。 D:\..

    错误 1 无法将程序集“NBear.Data.dll”复制到文件“D:\newbpm\bpm\SureBpm\Bin\NBear.Data.dll”.无法将“D:\newbpm\bpm\SureSof ...

  9. Dynamics CRM 2015/2016 Web API:Unbound Custom Action 和 Bound Custom Action

    今天我们再来看看Bound/Unbound Custom Action吧,什么是Custom Action?不知道的小伙伴们就out了,Dynamics CRM 2013就有了这个功能啦.和WhoAm ...

随机推荐

  1. 完全分布式Hadoop2.3安装与配置

    一.Hadoop基本介绍 Hadoop优点 1.高可靠性:Hadoop按位存储和处理数据 2.高扩展性:Hadoop是在计算机集群中完成计算任务,这个集群可以方便的扩展到几千台 3.高效性:Hadoo ...

  2. SQL 查询横表变竖表

    SQL 查询横表变竖表   /*普通行列转换 假设有张学生成绩表(tb)如下:Name Subject Result张三 语文 74张三 数学 83张三 物理 93李四 语文 74李四 数学 84李四 ...

  3. 2015北京网络赛 F Couple Trees 暴力倍增

    Couple Trees Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://hihocoder.com/problemset/problem/123 ...

  4. C++中的new与delete总结

    1. operator new.operator delete与new.delete操作符的区别: operator new的作用类似于malloc,负责分配内存:operator delete的作用 ...

  5. 由strupr,strlwr体会如果将字符常量转换为变量进行修改,体会常量的静态存储

    #include <stdio.h> #include <string.h> int main() { char s[]="Copywrite 1999-2000 G ...

  6. 对JavaScript对象数组按指定属性和排序方向进行排序

    引子 在以数据为中心的信息系统中,以表格形式展示数据是在常见不过的方式了.对数据进行排序是必不可少的功能.排序可以分为按单个字段排序和按多个字段不同排序方向排序.单字段排序局限性较大,不能满足用户对数 ...

  7. JSP的三种类型的元素

    JSP有三种类型的元素:指令元素(directive element).行为元素(action element).和脚本元素(script element). 指令元素用于指定整个JSP页面的相关信息 ...

  8. 数据结构及算法分析(0)——引论

          引论提到算法递归的概念,递归在很多算法中都会出现.所谓递归,当一个函数用它自己来定义的时候就称为递归.     递归调用有两大要素: 基准情况. 递归调用.     并非所有的数学递归函数 ...

  9. 浅析PAC,教你动手修改你的PAC文件及user-rule文件实现自动代理

    Shadowsocks作为现在一种很流行的穿墙工具,以其轻量级.速度感人等优点深受广大网友热捧.与VP_N相比,他就像一把锋利的”瑞士军刀”,不用受制于“系统全局代理”模式的困扰,控制更加便捷,基于S ...

  10. 基于Selenium2+Java的UI自动化(2) - 启动浏览器

    一.准备工作 我们常用的浏览器主要有三个:chrome.Firefox.IE:其中chrome 和 IE 需要下载驱动程序,才能启动浏览器,注意驱动程序有32位和64位两种. 另外:如何查看本机的浏览 ...