none
Is there a way of exporting a WebPart to obtain original coding when the original code has been lost RRS feed

  • Question

  • Hello,

    There are a few web-parts installed on our farm created by a predecessor and we need to obtain the c# code but are unable to locate this.

    This there a way of exporting the web-part to show all code rather than just the snippet of information that's provided?

    We need to edit a certain part of the webpart and are unable to do so unless we can find the code.

    Thanks

    Tuesday, February 28, 2017 11:30 AM

Answers

  • Custom developed webparts are never just .webpart files.  There is always a .DLL component.  If there isn't a .WSP that means they were deployed manually by copying the .DLL to the right location, making manual changes to the web.config file, and uploading the .webpart file.  If you open the .webpart file it will tell you which .DLL the web part is using.  YOu need to then find whether that .DLL has been uploaded to the BIN directory of the web site or the GAC and get a copy from there.

    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

    Tuesday, February 28, 2017 9:48 PM

All replies

  • If they were installed using a .WSP you can export that and extract the .DLL containing the code from that.  Or you can find the .DLL in eitehr the GAC or BIN directory where it was deployed and download from there.  Once you have the .DLL you can use ILSpy or something like that to disassemble the .DLL and get the code back.  Here''s a blog on how to export a .WSP

    https://sharepintblog.com/2011/06/04/exporting-solutions-packages-wsp-with-powershell/

    And here's one on how to use ILSpy to disassemble the code.

    http://www.dotnetforall.com/disassembling-net-code-using-ilspy/


    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

    Tuesday, February 28, 2017 12:41 PM
  • And if they're just .webparts?
    Tuesday, February 28, 2017 4:55 PM
  • Custom developed webparts are never just .webpart files.  There is always a .DLL component.  If there isn't a .WSP that means they were deployed manually by copying the .DLL to the right location, making manual changes to the web.config file, and uploading the .webpart file.  If you open the .webpart file it will tell you which .DLL the web part is using.  YOu need to then find whether that .DLL has been uploaded to the BIN directory of the web site or the GAC and get a copy from there.

    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

    Tuesday, February 28, 2017 9:48 PM