如何在没有原始源代码和签名密钥的情况下更改 VSTO C# 程序?

发布于 2025-01-14 04:35:59 字数 1027 浏览 2 评论 0原文

我们公司内部开发了一个用于 Microsoft Excel 的工具栏,但不幸的是,开发人员几年前离开公司后就不再拥有源代码了。于是,我开始反编译他的源代码,该源代码是用VSTO C#编写的,并且已经签名。

根据我的理解,所有 DLL 要么应该签名,要么不签名。因此,我开始删除强名称验证。使用强名称助手 (1)。在所有库中,我没有破坏任何东西,因为工具栏仍然可用。这表明我已经成功删除了所有签名。

从那里我打开 dnSpy (2) 并开始编辑 A.dll 中的一些小内容,我只需在其中添加2022年以学分文本作为测试。首先,我观察到 mscorlib (4.0.0.0) 已作为程序集加载。但是,如果我通过将 DLL 加载到 .NET 程序集强名称签名者 (3.1.1.0) (3),我得知 .NET 版本是 4.0.30319。

我的第一个问题是,如何确保加载正确的程序集 4.0.30319 而不是默认的 4.0.0.0?

编辑一小段代码后,我转到“文件”>“保存模块,然后按确定。这样就成功保存了新的dll。

现在,如果我在启用工具栏的情况下运行 Excel,那么工具栏就不会显示,也不会出现错误。工具栏根本处于非活动状态。我很难理解我忘记更新/更改哪一步以便能够编辑代码并正确加载工具栏。

也欢迎任何其他调试建议。

PS:我正在尝试在 Windows 11 上使用 Visual Studio 2019 执行此操作(如果这是相关的)。 PPS:我知道这是一个奇怪的请求,但我相信“修补”工具栏可以花费一些时间从头开始结构性地开发工具栏。

our company has internally developed a toolbar used in Microsoft Excel, however unfortunately the developer does not have the source code anymore since he left the company several years ago. Thus, I began decompiling his source code which has been programmed in VSTO C# and has been signed.

From my understanding, all DLLs should either be signed or not. So, I began removing the strong name verification. Using Strong Name Helper (1). From all the libraries, I have not broken something, as the toolbar is still readily available. This suggests that I have successfully removed all the signing.

From there I open dnSpy (2) and start editing something small in A.dll, where I simply add 2022 to the credit text as a test. First, thing I observe is that mscorlib (4.0.0.0) has been loaded as an assembly. However, if I check the .NET version by loading the DLL into .NET Assembly Strong-Name Signer (3.1.1.0) (3), I get that the .NET version is 4.0.30319.

My first question, would be then how can I ensure that the correct assembly 4.0.30319 is loaded instead of the default 4.0.0.0?

After editing the small section of code, I go to File > Save Module and then press OK. This succesfully saves the new dll.

Now, if I run the Excel with the toolbar enabled, then the toolbar simply won't show up, nor an error comes out. The toolbar simply is inactive. I am struggling to understand which step have I forgotten to update / change in order to be able to edit the code and load the toolbar properly.

Any other debugging suggestions are also welcome.

PS: I am trying to do this on a Windows 11 with Visual Studio 2019 (if that's rekevant).
PPS: I understand this is a weird request, but I believe that "patching" the toolbar buys a bit of time to structurally develop the toolbar from scratch.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ゞ花落谁相伴 2025-01-21 04:35:59

您可以在 Visual Studio 中创建一个新的 VSTO 外接程序,然后只需从反编译的外接程序中复制代码,这样您将拥有更好的方法来构建软件。 dotPeek 可以帮助您。

请注意,旧源代码中使用的技术可能会随着时间的推移而改变。例如,命令栏已被弃用,并且不能用于自定义 Office UI。相反,您需要使用 Fluent UI(又名 Ribbon UI)。

您可能会发现演练:创建您的第一个 VSTO Excel 加载项 很有帮助。

You can create a new VSTO add-in in Visual Studio and then just copy the code from the decompiled add-in, so you will have a better approach for building the software. dotPeek can help you with that.

Be aware, techniques used in the old source code could be changed with a time. For example, command bars were deprecated and can't be used for customizing the Office UI. Instead, you would need to use the Fluent UI (aka Ribbon UI) instead.

You may find the Walkthrough: Create your first VSTO Add-in for Excel helpful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文