'How to change VSTO C# program without the original source code nor signing key?

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.



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Eugene Astafiev