Click here to Skip to main content
13,707,665 members
Click here to Skip to main content
Add your own
alternative version


50 bookmarked
Posted 25 Apr 2005

Playing around with System.Reflection.Assembly.LoadFrom

Rate this:
Please Sign up or sign in to vote.
Some more or less cool functionality with late binding of assemblies.


There are some very nice areas in the CLR, for example the whole area of reflection. Nowadays, developers use reflection, its functionalities for their projects. But it's nearly impossible to know all about these functions.

So I made some test just on the Assembly.LoadFrom and played around with it...


Private Sub Test()
 Dim extAssembly As System.Reflection.Assembly = _

 Dim extForm as Form = _
      extAssembly.CreateInstance("WindowsApplication2.Form1", True)

End Sub

For those who use system reflection, there is a common piece of code. We load an external assembly from the file system, create an instance of the form within that assembly, and add it to our Forms collection to display it later on.

Naming of the assemblies

Now, if we use references in our projects, we can only reference DLL files. But with System.Reflection, we can refer to any file name. We can give our files any name and it works. This makes hacker's life a bit more complicated.

Dim extAssembly As System.Reflection.Assembly = _

Use a web reference to the assembly

We are able to just use a URL instead of locating the assembly in our own network.

Dim extAssembly As System.Reflection.Assembly = _
     System.Reflection.Assembly.LoadFrom("" & _ 

And it works - yes, it works very fast. Now think about using a password protected feature within your app before you download the assembly from the web. And think about the way it works - there is no local assembly. It is just loaded within your app domain, and after you close your application, nothing will be found on the users hard drive. This way, one is not able to de assemble your code or use it on his own with System.Reflection- as long as he does not know where it is....

Use a webpage

This is the most coolest part of it. Instead of directly referencing the assembly, we are calling a webpage on our Web Server (for test purpose just do with classic ASP) and suddenly, we see a wide range of potential in it.

Dim extAssembly As System.Reflection.Assembly = _
   System.Reflection.Assembly.LoadFrom _

The content of our callmyexe.asp is that easy:

<%@ Language=VBScript %>

But you'll see the following potential within it:

  • Generate a URL that also provides some security information. (i.e. any keys.)
  • Our website can check some security as well. (i.e. check the calling IP.)
  • We use some parameters in our URL so that the webpage decides what kind of assembly we receive.
  • We can store our assemblies within a database and give them back - and our directories do not contain any of the assemblies.
  • At least, with CodeDom, we are able to generate an assembly ad hoc and give it back to the caller.

So, have fun making your own tests.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Daniel Ch. Bloch (MCSD, MCAD, MCTS)
Software Developer (Senior)
Switzerland Switzerland
On software development since 1992, going through the different steps from mainframe computing with VMS/Vax over VB4-6, Access and SQL server, Cold Fusions and ASP programming to my currently status as Chief Solution Developer for Smartclient and Client/Server development with and SQL Server. MCSD and some other stuff.

You may also be interested in...

Comments and Discussions

Generalthanks Pin
Elias Bachaalany21-Jun-07 21:34
memberElias Bachaalany21-Jun-07 21:34 2003- extract image using assembly Pin
minad_78611-Apr-07 3:51
memberminad_78611-Apr-07 3:51 
GeneralParameters Pin
marco gheri21-Nov-06 9:10
membermarco gheri21-Nov-06 9:10 
QuestionBut is ofusqued?? Pin
Javea6514-Jun-05 6:03
memberJavea6514-Jun-05 6:03 
AnswerRe: But is ofusqued?? Pin
anotherbla00114-Jun-05 18:56
memberanotherbla00114-Jun-05 18:56 
GeneralRe: But is ofusqued?? Pin
Javea6514-Jun-05 21:11
memberJavea6514-Jun-05 21:11 
GeneralAssembly.LoadFrom from GAC Pin
6-Jun-05 12:17
member6-Jun-05 12:17 
GeneralRe: Assembly.LoadFrom from GAC Pin
Daniel Ch. Bloch (MCSD, MCAD, MCTS)14-Jun-05 19:03
memberDaniel Ch. Bloch (MCSD, MCAD, MCTS)14-Jun-05 19:03 
GeneralBeautiful work! Pin
Phan Dung4-May-05 16:49
memberPhan Dung4-May-05 16:49 
GeneralCorrection Pin
J. Dunlap25-Apr-05 21:27
memberJ. Dunlap25-Apr-05 21:27 
GeneralRe: Correction Pin
Daniel Ch. Bloch (MCSD, MCAD, MCTS)25-Apr-05 22:39
memberDaniel Ch. Bloch (MCSD, MCAD, MCTS)25-Apr-05 22:39 
GeneralRe: Correction Pin
dshorter14-May-05 4:54
memberdshorter14-May-05 4:54 
GeneralRe: Correction Pin
Daniel Ch. Bloch (MCSD, MCAD, MCTS)5-May-05 20:27
memberDaniel Ch. Bloch (MCSD, MCAD, MCTS)5-May-05 20:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.180920.1 | Last Updated 26 Apr 2005
Article Copyright 2005 by Daniel Ch. Bloch (MCSD, MCAD, MCTS)
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid