简体   繁体   English

SSIS:如何调试在脚本组件内部引用的自定义程序集

[英]SSIS: How to debug a custom assembly that is referenced inside of a script component

I am able to debug custom components that are added to SSIS through Visual Studio's Attach to Process feature.我能够调试通过 Visual Studio 的Attach to Process功能添加到 SSIS 的自定义组件。

However, is it possible to debug a custom assembly while it is being executed inside of an SSIS package's script component (ie, C# script within the data flow)?但是,是否可以在 SSIS 包的脚本组件(即数据流中的 C# 脚本)内部执行自定义程序集时对其进行调试? If yes, how?如果是,如何?

I have tried the following without success:我尝试了以下方法但没有成功:

  1. Build the assembly with breakpoints (see Note at the bottom of this question) *使用断点构建程序集(请参阅此问题底部的注释) *
  2. Start the SSIS package and halt the execution at a breakpoint启动 SSIS package 并在断点处停止执行
  3. Attached the instance of Visual Studio that has the assembly file open to the executing instance of DtsDebugHost.exe that is running the SSIS package将打开程序集文件的 Visual Studio 实例附加到正在运行 SSIS package 的 DtsDebugHost.exe 执行实例

All of the breakpoints within the assembly file switch over to say:汇编文件中的所有断点都切换为:

The breakpoint will not currently be hit.当前不会命中断点。 No symbols have been loaded for this document.没有为此文档加载任何符号。

What symbols am I supposed to load?我应该加载哪些符号? I checked the modules window, but loading the three assemblies do not help and when I try to load symbols for the two SqlServer DTS assemblies it requires me to pick a very specific file of the same file name and file type where both appear to be temporary file names - I have no idea what to load here.我检查了模块 window,但是加载三个程序集没有帮助,当我尝试为两个 SqlServer DTS 程序集加载符号时,它需要我选择一个非常特定的文件,它的文件名和文件类型都相同,这两个文件似乎都是临时的文件名 - 我不知道在这里加载什么。

模块窗口

*Note: I have the following post-build events setup on the custom assembly: *注意:我在自定义程序集中设置了以下构建后事件:

"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\gacutil.exe" -u $(TargetName)
"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\gacutil.exe" -i $(TargetFileName)
copy $(TargetFileName) "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8"
copy $(TargetFileName) "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\SSIS\150\Binn"

UPDATE 1更新 1

Before posting this question, I also tried adding the assembly's source code files into the script component's, but that resulted in other errors being thrown that were unrelated to the original error that I was trying to debug.在发布此问题之前,我还尝试将程序集的源代码文件添加到脚本组件中,但这会导致引发与我尝试调试的原始错误无关的其他错误。 There is a lot of recursion inside the assembly and it also has code that tries to load it's own assembly.程序集中有很多递归,它也有尝试加载它自己的程序集的代码。 I was unable to understand exactly what was causing the unrelated errors.我无法准确理解是什么导致了不相关的错误。 So, I gave up on that route.所以,我放弃了这条路线。

One other point that is perhaps worth mentioning, if not strictly for programmer humor, this assembly is very old with little to no code comments.可能值得一提的另一点是,如果不是严格地出于程序员的幽默,这个程序集非常古老,几乎没有代码注释。 When I found it's source code in our code repo it would not open because it was still targeting .NET Framework 2.0, which is not even available for download from Microsoft.当我在我们的代码仓库中发现它的源代码时,它不会打开,因为它仍然针对 .NET Framework 2.0,甚至无法从 Microsoft 下载。 I had to upgrade it, so I selected .NET Framework 4.8.我不得不升级它,所以我选择了 .NET Framework 4.8。 I tried switching to 4.7 as the script component targets 4.7 by default and is somewhat hard-coded that way because every time I save and re-open it, it downgrades back to 4.7.我尝试切换到 4.7,因为脚本组件默认以 4.7 为目标,并且这种方式有点硬编码,因为每次我保存并重新打开它时,它都会降级回 4.7。 But, neither .NET Framework versions resolve my ability to debug the assembly within the script component.但是,.NET 框架版本都没有解决我在脚本组件中调试程序集的能力。

So, I have resorted to adding text file writelines that output where the code reaches before erroring out.因此,我求助于在出错之前添加代码到达的 output 的文本文件写入行。 This is a lame way to debug IMHO.这是调试恕我直言的蹩脚方式。

UPDATE 2更新 2

I attempted to load the symbols for Microsoft.SqlServer.ManagedDTS.dll and the open-file dialog window is looking for either Microsoft.SqlServer.ManagedDTS.pdb or Microsoft.SqlServer.ManagedDTS.dbg .我试图加载Microsoft.SqlServer.ManagedDTS.dll的符号,打开文件对话框 window 正在寻找Microsoft.SqlServer.ManagedDTS.pdbMicrosoft.SqlServer.ManagedDTS.dbg I went into C:\Program Files (x86)\ and ran the following:我进入C:\Program Files (x86)\并运行以下命令:

  • dir /s /b Microsoft.SqlServer.ManagedDTS.pdb
  • dir /s /b Microsoft.SqlServer.ManagedDTS.dbg

But, the response to both was File Not Found .但是,对两者的响应都是File Not Found Any ideas?有任何想法吗?

加载 ManagedDTS 符号

I was not able to find a way to debug the assembly during the execution of the SSIS package.在执行 SSIS package 期间,我无法找到调试程序集的方法。 I had to retrieve the row's data from the SSIS package and then feed it into the assembly through a console application, as @billinkc had previously suggested.正如@billinkc 之前建议的那样,我必须从 SSIS package 检索行的数据,然后通过控制台应用程序将其输入到程序集中。 I will leave this question up.我会留下这个问题。 If anyone has a better answer in the future then please do share it.如果将来有人有更好的答案,请分享。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM