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

The proplem

Lately, I worked on the Social connected module 2.1 and integrated it with Sitecore 7.2. After installing the module, and fix this known issue that make 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 spend alot 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 socail connected module. It is caused by changes in these social networks APIs.

So the first thing poped into my head is changing these keys. Theoretically everything should works good.

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

The solution

I used Ildasm and ilasm to achive 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 achive this:

  • Open Developer Command Prompot as administrator.
  • Enter the command ' ildasm ', the appilcation will be opend, then open the dll.
  • File -> Dump, then you will generate a file with .il extention.
  • Use any text editor to update the genrated 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 follwoing command to recompile the modified code

ilasm C:\inetpub\wwwroot\sc72rev151021\recompiled\ /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, the I put it in the bin folder of the site, and the error was fixed.

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