Re: [mono-cecil] How to embed resource?

470 views
Skip to first unread message

Jb Evain

unread,
Sep 10, 2012, 3:38:19 AM9/10/12
to mono-...@googlegroups.com
Hey,

Visual Studio usually prefixes the resource name with a namespace
based on the folder they're into.

So instead of “EmbeddedBinaryFileName”, they may be in
NamespaceDummy.EmbeddedBinaryFileName or
NamespaceDummy.Resources.EmbeddedBinaryFileName.

Make sure you match the original name of the resource.

Have a good night!

Best,

Jb

On Mon, Sep 10, 2012 at 6:16 AM, cryogen <b...@secnews.pl> wrote:
> Hi,
>
> I want to embed a binary resource (byte[] array) to an existing assembly, so
> it can be read by the assembly like this:
>
> MemoryStream streamSelf = new
> MemoryStream(global::NamespaceDummy.Resources.EmbeddedBinaryFileName);
>
> so I was trying to do:
>
> EmbeddedResource res = new EmbeddedResource("EmbeddedBinaryFileName",
> ManifestResourceAttributes.Public, binaryFile.ToArray());
> assembly.MainModule.Resources.Add(res);
>
> but after modifications, original assembly can't find this resource. If I
> add it manually within Visual Studio and I open it with .NET Reflector I can
> see resources has different layout.
>
> It's 5am and I need some help :)
>
>
> --
> --
> mono-cecil

dataprot...@gmail.com

unread,
Apr 1, 2019, 1:05:27 PM4/1/19
to mono-cecil
Hello.
I apologize for posting here, but is there any way we can compress the embedded resource?
With respect,
Adrian

Jb Evain

unread,
Apr 4, 2019, 2:15:59 PM4/4/19
to mono-...@googlegroups.com
Hi,

Sure, in the end the resource is just a Stream or a byte array, the content of those could very well be compressed. You'd just need to make to also decompress them before reading them :)

Jb

--
--
--
mono-cecil
---
You received this message because you are subscribed to the Google Groups "mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mono-cecil+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages