Social Connected Module: Updating DLLs on the FLY (using ildasm and ilasm)

The issue

Lately, I worked on the Social connected module 2.1 and integrated it with Sitecore 7.2. After installing the module, and fixing this known issue that makes it compatible with Sitecore 7.2, I was shocked that this module is not working, and it was not able to connect the social media users to the website.

After spending a lot of time checking the logs, intercepting the requests between the social network apps, reflecting the code I found that this module uses deprecated facebook keys, and these keys are hardcoded in the DLLs of this application.

This is not a problem with the socially connected module. It is caused by changes in these social networks' APIs.

So the first thing that popped into my head is changing these keys. Theoretically, everything should work well.

The second thing was the fastest way of doing this. They are just hardcoded keys.

The solution

I used Ildasm and ilasm to achieve this:

1- Recompile the dll.
2- Dump the file and update the code.
3- Rebuild it.

Ildasm.exe (IL Disassembler) is a companion tool to the IL Assembler (Ilasm.exe). Ildasm.exe takes a portable executable (PE) file that contains intermediate language (IL) code and creates a text file suitable as input to Ilasm.exe.

ILAsm (IL Assembler) generates a portable executable (PE) file from Common Intermediate Language (CIL) code. It is not to be confused with NGEN (Native Image Generator), which is the JIT compiler for the Microsoft .NET Framework.

The steps to achieve this:

  • Open Developer Command Prompt as administrator.
  • Enter the command ' ildasm ', the application will be opened, then open the dll.
  • File -> Dump, then you will generate a file with .il extention.
  • Use any text editor to update the generated file, and change the hardcoded values in the code. In my case, I had to change the hardcoded keys like "first_name" and "last_name" to "name".
  • The last step is to use ilasm to recompile the code, I used the following command to recompile the modified code

ilasm C:\inetpub\wwwroot\sc72rev151021\recompiled\Sitecore.Social.Facebook.il /resource=c:\inetpub\wwwroot\sc72rev151021\recompiled\Sitecore.Social.Facebook.res /dll/output=C:\inetpub\wwwroot\sc72rev151021\recompiled\Sitecore.Social.Facebook2.dll /include=C:\inetpub\wwwroot\sc72rev151021\recompiled\Sitecore.Social.Facebook.dll

Now I have a compiled dll with the fix, then I put it in the bin folder of the site, and the error was fixed.

P.S. I faced another error from this module, and I fixed them. In the next post, I will write how I fixed them and make this module work.

Subscribe to Ahmad Harb

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe