Unpacking .dll from .xll

291 views
Skip to first unread message

Tjaart van Wijck

unread,
Dec 9, 2010, 1:47:50 PM12/9/10
to Excel-Dna
What is a good way to unpack the .dll from a packed .xll?

I have a number of packed .xll add-ins and need to do some reflection
on the packed managed assemblies.

Govert van Drimmelen

unread,
Dec 10, 2010, 3:13:46 PM12/10/10
to Excel-Dna
Hi Tjaart,

Are you asking how to do this at runtime?
The assemblies are loaded into the AppDomaim of the add-in (for your
code this will be AppDomain.CurrentDomain). The AppDomain has a
GetAssemblies function that returns the currently loaded assemblies,
from where you can examine them with reflection.

-Govert

Tjaart van Wijck

unread,
Dec 12, 2010, 9:12:52 AM12/12/10
to exce...@googlegroups.com
Hi Govert,

Thanks for the response but this is not exactly the problem I'm faced with and I think I should clarify.

I'm building an Excel Add-In which allows users to dynamically build assemblies and pack them with the Excel DNA wrappers into a .xll. The Add-In also gives the user the ability to browse the catalog of generated .xlls with information about which methods are exposed by each. I do not want to hold separate files with meta-data about each .xll.

What I want to do is,
1) Create a new App-Domain
2) Strip out the managed assemblies from the .xlls
3) Load them into the App-Domain
4) Gather meta-data using reflection
5) Dispose the App-Domain

I'm having trouble with the second step.

Many thanks,
-Tjaart

--
You received this message because you are subscribed to the Google Groups "Excel-Dna" group.
To post to this group, send email to exce...@googlegroups.com.
To unsubscribe from this group, send email to exceldna+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/exceldna?hl=en.


Govert van Drimmelen

unread,
Dec 12, 2010, 4:01:50 PM12/12/10
to Excel-Dna
Hi Tjaart,

Oh, I see. It sounds very cool - I hope you'll post a bit more about
what you are doing (if it's not a trade secret).

The code you need for your step 2 is in AssemblyManager.cs in the
ExcelDna.Loader project.
You should make a copy of the ResourceHelper class for your code, and
you also need copies of the compression stuff under the Source\Lzma
directory.
Then you call ResourceHelper.LoadResourceBytes(hModule, typeName,
resourceName), where
* hModule is returned from GetMoudleHandle or LoadLibrary,
* typeName is "ASSEMBLY", and
* resourceName is something like "MYLIB".

Note that I see aspects like the compression and the naming of the
embedded resources as implementation details, so these might easily
change in future versions.
You'll need to check the source again if anything gets broken.

Regards,
Govert
> > exceldna+u...@googlegroups.com<exceldna%2Bunsubscribe@googlegroups.c om>
> > .

Tjaart van Wijck

unread,
Dec 13, 2010, 1:57:00 AM12/13/10
to exce...@googlegroups.com
Thanks Govert.

I'm aiming to have a website up within the next two months or so.

To unsubscribe from this group, send email to exceldna+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages