[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

[C#] How to read DLL to array of bytes?

Posted on 2009-04-15
2
Medium Priority
?
406 Views
Last Modified: 2013-12-17
Hello,
How to read DLL file from hard disk and load it to my app into byte array? My dll file is in same folder what my application .exe. I don't want to use this dll in this app I wanna only read it into array of byte and send this array to another app.
Thx a lot

Regards
0
Comment
Question by:F0x88
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
HarryNS earned 1500 total points
ID: 24145959
You can go for Reflection... You can read a dll using reflection
Assembly a = Assembly.Load("helloworld");

Pass this object to another app.
0
 
LVL 2

Author Comment

by:F0x88
ID: 24148922
hmm I don't know how to call later methods in another application if I good using it. I have server and client app. on server I have my class HelloWorld(this class can be in DLL what using server but its not that important), I just want to return this class to client app as assembly, on RemotableObject class I have only interface with method what returns this assembly class. Check my code... remote client have error during Assembly RemoteClass = objget.GetClass();
Could not load file or assembly 'HelloClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

why? I can't send my class/dll to another app and use thier methods?
server app:
...
using HelloClass;
 
namespace RemoteServerApplication
{
    public class HelloServer : MarshalByRefObject, IExecute
    {
 
        public Assembly GetClass()
        {
            Assembly a = Assembly.Load("HelloClass");
            return a;
        }
 
    }
}
 
HelloClass in dll file(referenced only to server):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace HelloClass
{
    public class HelloWorld
    {
        public void TestMe()
        {
            Console.WriteLine("Test string what will be writen in client.");
        }
    }
}
 
remotable object with interface(referenced to client and server):
public interface IExecute
    {
        Assembly GetClass();
    }
 
 
client gets this assembly:
IExecute objget = (IExecute)Activator.GetObject(
                    typeof(IExecute), "tcp://localhost:8085/RemoteTestRef");
            if (objget == null)
                Console.WriteLine("Could not locate server");
            else
            {
           
                Assembly RemoteClass = objget.GetClass();
}

Open in new window

0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question