|
Hi Peeps, Is there a way of getting the source code from a CLR assembly? We have a database created by another department that has a CLR assembly used in a SP, and we need to change the CLR because it is referencing a column that doesn't exist anymore and we need to update it. Can we update the CLR without the source code, or is there a way to get the source code from the assembly.
(comments are locked)
|
|
I haven't done with a SQL CLR assembly, but .NET Reflector from Red-Gate works very well to reverse engineer .NET assemblies. I didn't even think of using reflector, thanks. I used the script from this link to save the dll to the hard drive. http://serverfault.com/questions/139703/extracting-a-sqlclr-assembly
May 08 '11 at 10:11 PM
Daniel Ross
(comments are locked)
|
|
I'll add an answer in here... 1 - The script to extract the assembly from the database at http://serverfault.com/questions/139703/extracting-a-sqlclr-assembly is not correct. 2 - .NET reflector does not always decompile things correctly. I have had instances in the past where I have been decompiling something in order to recompile it, and the recompiled version has been subtly different. An example of this was when trying to decompile and recompile a third party T-SQL script parsing component - it looked like it worked, but then fell over on some of the less obvious code paths - so definitely tread with caution. Great point that seems to hold true for many decompilers
May 09 '11 at 05:26 AM
KenJ
+1, very true...
May 09 '11 at 07:57 AM
Matt Whitfield ♦♦
@Matt Whitfield I would like to ask about another possibility. Usually, the reflectors are designed to use instances/static methods of the System.Reflection types to reflect into the source types querying for methods/properties with different combination of the flags (thus the name - reflector). The other alternative is to use the ildasm tool provided by .NET Framework. This tool gives a complete copy of the source assembly in MSIL language unless the latter was compiled with ngen (it makes no assumptions/changes whatsoever). This is why they say to never include any sensitive info into the binary :) While MSIL is not trivial to understand, it still shows the source in plain text, so if all that is needed to be changed is limited to removing the column from the embedded query then it appears that it could be suffifient to edit the MSIL by hand and then compile it back to DLL. This way, the logic of the code will certainly remain the same. This way it would be possible to implement the change even if the source was treated by the Obfuscator which usually makes the refectors scratch their heads. Do I make any sense or I simply need more coffee?
May 09 '11 at 08:21 AM
Oleg
@Oleg - you definitely make sense - but editing MSIL by hand is certainly not for the feint hearted - it's not a route I'd take unless it was an absolute emergency... :)
May 10 '11 at 01:21 AM
Matt Whitfield ♦♦
@Oleg - also, congrats on the 10k sir! :)
May 10 '11 at 08:10 AM
Matt Whitfield ♦♦
(comments are locked)
|

