Problem when putting a dll or binary as resource c #

0

Usually when I put a dll or binary as a resource I upload it to a page and download the data as follows:

web.DownloadDataAsync(new Uri("http://pagina/dll/ejemplo.dll"));

Now what I was trying to do was to put it as a resource in the following way:

b = Assembly.GetExecutingAssembly().GetManifestResourceStream("espaciodenombres.ejemplo.dll");

The problem is that now it returns me the following error.

  

You can not implicitly convert the 'System.IO.Stream' type into   byte []

How could I put it as a resource and read it without having to host it on a web server ??

    
asked by Tecnology Now 24.10.2017 в 16:19
source

1 answer

0
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("espaciodenombres.ejemplo.dll"))
{
    using (StreamReader reader = new StreamReader(stream))
    {
        string resultado = reader.ReadToEnd();
    }
}

So you have it in a string, if you want it in a byte []

using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("espaciodenombres.ejemplo.dll"))
{
    using (StreamReader reader = new StreamReader(stream))
    {
        byte[] resultado = Encoding.ASCII.GetBytes(reader.ReadToEnd());
    }
}

If you want to use the dll directly in the application, you have to go to References - > right click Add Reference and where Browse search for the path where you have the dll you want to use.

    
answered by 24.10.2017 в 16:31