Hack Forums
[C#] My resource would not be linked in my project bug - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] My resource would not be linked in my project bug (/showthread.php?tid=5720722)



My resource would not be linked in my project bug - Nimrod - Sep 19, 2017

Hi,

I kill my skull for a few hours now with an incoherent bug ... be saying my resource would not be linked in my project, while it is well ...

If someone can help me ... because I do not understand anything about all this error and google is not my friends

Here is a screen via dnspy for view resources i here and bug is here:

[Image: 175068Capture.png]


and the functions I use to write and read in my resources ...

Builder side:
Code
string NameResFile = Utils.Settings.RandomString(rand.Next(5, 25 + 1));
string res1 = Utils.Settings.RandomString(rand.Next(5, 80 + 1));
string ResFile = Path.Combine(Application.StartupPath, NameResFile + ".resources");

using (ResourceWriter Writer = new ResourceWriter(ResFile))
            {
                Writer.AddResource(res1, compress);
                Writer.Generate();
            }
Stub side:
Code
public static byte[] ReadManaged(string RessourceAdded, string filename)
        {
            ResourceManager Manager = new ResourceManager(filename, Assembly.GetExecutingAssembly());
            byte[] bytes = (byte[])Manager.GetObject(RessourceAdded);
            return bytes;
        }
I use ReadManaged like that:

Code
byte[] myRes = ReadManaged("GoiqViIZBLCDeZlackUfLySPXzEpyCNcRZZOWzGYRyI", "IfoTjzHillpCiyJeg");

I thank all those who can help me


* - gigajew - Sep 19, 2017

These resources should help you

ResourceManager constructor (namespace, assembly)
In your case: ResourceManager("crypted.crypted.Resources", Assembly.GetExecutingAssembly())
https://msdn.microsoft.com/en-us/library/yfsz7ac5(v=vs.110).aspx

And

ResourceManager.GetObject(object name) method
In your case: resourceManager.GetObject("encrypted payload")
https://msdn.microsoft.com/en-us/library/963f81yd(v=vs.110).aspx


Also a personal tip, don't declare your resourcemanager on every call to ReadManaged, rather set it class-level and make ReadManaged only call getobject