Extract & Grab Resources From Dot Net Assembly in VisualBasic.Net
Introduction
This tip demonstrates how to retrieve
resources from a Dot Net Assembly and the purpose is to share and learn.
Background
Recently, for fun only and to do something useful in my spare time, I was
looking for a library to retrieve all resource files from a Dot Net Assembly in
VisualBasic.Net?. Actually it is not quite difficult to handle resources files
from Windows Form’s project and there is so many ways to deal with resources
where you can store several type of files such as but not limited to........
dll, exe, text, image, xml ...and.......so on. The question was how I can do
it?
Why Shall I Use Resources
May be it is seems a silly question for some coders but actually it is not,
because I saw so many questions here and there asking about resources, how to
extract and how to handle it. Anyhow my understanding to such a question is
quite simple, resources represents data might needed by an application and to
be stored or embedded directly into your application or by any other means.
however, since there is no a library written particularly to Visual
Basic.net, I have decided to give it a try then started read here and there and
finally was able to do it, and here it is the library, it is dedicated to all
VisualBasic.net community.
Classes of The Library
These are the class and interface which make up the resources Grabber:
IGrabber
Represents, the base interface of the Grabber Class.
Grabber
Represents, the class that used to retrieve resources
from an Assembly. Please refer to the attached file
Delegates
Represents, the delegates will occur as required by the
Grabber class.
Grabber Class
The idea behind the grabber
Class is to load an assembly and extract any resources within it and save under
your application directory.
Grabber Properties
Events:
Represents, EventHandlerList property used to store
Grabber’s Delegates; it can not be changed by derived classes.
Refer to: Declare Custom Events to Conserve Memory
Also, you may refer to my Article in CodeProjet; Add
Custom Event to a Class in VB.NET
Folder:
Represents: - String property used to gets or set the location where the
grabbed resources to be saved, it can be changed by derived classes.
File:
Represents: - String property used to gets/set the assembly file name used
to grab resources from it and can be changed by derived classes.
Search:
Represents: - Flag property to check sub-folders of Assembly file.
Grabber Events
GrabCompleted:
Represents, a Custom Event occurs when grab is completed.
GrabStarted:
Represents, the Custom Event
occurs when grab is started.
GrabberException:
Represents, Custom Event occurs
when an exception is thrown during grabbing.
Grabber Methods
Grab:
Represents, public method used to grab or retrieve
resources from an Assembly.
GrabResources:
Represents, overloaded friend methods used to load an assembly and grab or
retrieve resources from it.
CancelGrabbing:
Represents, public method used to cancel or stop grab
operation
GetFileName:
Represents, public shared method to get file name from a
string.
For Further details, Please download the source code which shows how to do it ……. Enjoy it....I hope!!!!!
References
- http://www.codeproject.com/Articles/229122/Add-Custom-Event-To-A-Class-in-VB-Net
- http://msdn.microsoft.com/en-us/library/vstudio/system.threading.parameterizedthreadstart
- http://msdn.microsoft.com/en-us/library/yt1k2w4e.aspx
- http://msdn.microsoft.com/en-us/library/70s77c20%28v=vs.110%29.aspx
- http://support.microsoft.com/kb/837908
- http://www.codeproject.com/Articles/13573/Extracting-Embedded-Images-From-An-Assembly
- http://www.nirsoft.net/utils/dot_net_resources_extract.html
Points of Interest
I knew the library is not perfect and almost it has been
collected from my readings and studding of different similar codes in the
network, but the benefits behind such a code is; now I have a good idea how to
protect the dot net library and hope to share with you ASAP
Link 2 @ vb4arab
Comments
Post a Comment