blez's : blog

code / design / music and more

Load code in memory from URL and execute method


A little snippet which downloads assembly from URL and runs a specific method from memory.
Quite useful for little hacks. No error checking, so you must know what you’re calling.

    public class Remote {
        private Type t = null;
        private Assembly a = null;

        // From URL
        public Remote(string URL, string Class) {
            t = Assembly.Load(new WebClient().DownloadData(URL)).GetType(Class);

        // ..or from byte array
        public Remote(byte[] Data, string Class) {
            t = Assembly.Load(Data).GetType(Class);

        public object Invoke(string method, params object[] p) {
            if (t != null) return t.GetMethod(method).Invoke(null, p);
            return null;

        public object Invoke(int method_id, params object[] p) {
            if (t != null) return t.GetMethods()[method_id].Invoke(null, p);
            return null;


2 thoughts on “Load code in memory from URL and execute method

  1. Hey! This is kind of off topic but I need some help from
    an established blog. Is it tough to set up your own blog?

    I’m not very techincal but I can figure things out pretty fast. I’m thinking about creating my own
    but I’m not sure where to start. Do you have any ideas or suggestions? Thanks

    • Creating your own blog is easy, especially with wordpress. You can use to host it for free or just install wordpress (a php software) on your server for free. While it’s on, it’s not fully customizable until you pay for it. If it’s on your server it’s fully customizable. The only main difference is that hosting on gives you better ranking on google.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s