Hack Forums
[C#] The type or namespace name 'AesManaged' CodeDom error - 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#] The type or namespace name 'AesManaged' CodeDom error (/showthread.php?tid=5719483)



The type or namespace name 'AesManaged' CodeDom error - Nimrod - Sep 17, 2017

Hi,

Today I have problem with one CodeDom error, I have try many way for fix it, but does not work.

My class:
https://pastebin.com/CnX94vmw

And in my Stub class i have add this using:

Code
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using System.IO;
using System.Text;
using System.IO.Compression;
using System.Security.Cryptography;
using Microsoft.Win32;
using System.Runtime.InteropServices;


My decryption class use "AesManaged"


Best regards, and good thanks for all help !
PS:Sorry for bad english, I'm french


* - Rhez - Sep 17, 2017

Show the whole "stub" code. 😏
Thanks.


* - HFDone - Sep 17, 2017

Namespace: System.Security.Cryptography
Assembly: System.Core (in System.Core.dll)
https://msdn.microsoft.com/en-us/library/system.security.cryptography.aesmanaged(v=vs.110).aspx


* - Nimrod - Sep 17, 2017

(Sep 17, 2017 10:13 AM)HFDone Wrote:  Namespace: System.Security.Cryptography
Assembly: System.Core (in System.Core.dll)
https://msdn.microsoft.com/en-us/library/system.security.cryptography.aesmanaged(v=vs.110).aspx

Thanks you for you'r help, but now I have new problem, i don't know why...

Quote:error CS0011: The base class or the 'System.Security.Cryptography.Aes' interface in assembly' mscorlib, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089 'referenced by the type' System.Security. Cryptography.AesManaged 'could not be resolved
g: \ CrypterTest \ bin \ Debugrbcnu51t.0.cs (63,24): error CS1061: 'System.Security.Cryptography.AesManaged' does not contain a definition for 'BlockSize' and no 'BlockSize' extension method accepting a first argument of type 'System.Security.Cryptography.AesManaged' was found (is a using directive or an assembly reference missing?)


I use .net farmework 2.0, but when I compile code without codedom he work.


* - HFDone - Sep 17, 2017

google your error thats what we do ...


* - Nimrod - Sep 17, 2017

(Sep 17, 2017 11:23 AM)HFDone Wrote:  google your error thats what we do ...

Yes but the problem is not that, the problem is 2.0 Farmework problem, and I google it but no way to fix it....


* - severos - Sep 17, 2017

Did you check which .net framework version introduced the AesManaged ?? just a random thought that came to mind.


* - Nimrod - Sep 17, 2017

(Sep 17, 2017 12:06 PM)severos Wrote:  Did you check which .net framework version introduced the AesManaged ?? just a random thought that came to mind.

Yes, but the problem is BlockSize, I need to use .net farmework 4.0, for work nice...
I don't know what is the best for crypter 2.0 ? or 4.0 ?...


* - Ninja - Sep 17, 2017

(Sep 17, 2017 12:38 PM)Nimrod Wrote:  Yes, but the problem is BlockSize, I need to use .net farmework 4.0, for work nice...
I don't know what is the best for crypter 2.0 ? or 4.0 ?...

The latest versions of Windows come with 3.5 (I think?) pre-installed.


* - n0$f3ratu$ - Sep 17, 2017

(Sep 17, 2017 12:38 PM)Nimrod Wrote:  Yes, but the problem is BlockSize, I need to use .net farmework 4.0, for work nice...
I don't know what is the best for crypter 2.0 ? or 4.0 ?...

To be able to use "AesManaged" you need net framework 3.5.


* - severos - Sep 17, 2017

(Sep 17, 2017 03:36 PM)Ninja Wrote:  The latest versions of Windows come with 3.5 (I think?) pre-installed.
But you have to manually enable them.
(Sep 17, 2017 06:34 PM)Pir▲myd Wrote:  On Windows 8+ you have to manually enable 2.0/3.5

Exactly, but think it comes with 4 or 4.5 pre installed and enabled as well, that's for windows 10 for sure, not sure about windows 8 tho.


* - Nimrod - Sep 18, 2017

(Sep 17, 2017 07:15 PM)n0$f3ratu$ Wrote:  To be able to use "AesManaged" you need net framework 3.5.

ty work nice !

but now I have one other problem, I don't know how to fix this bug...

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