|
Thanks a lot.
But doing this will cause the header be compressed with the data.
|
|
|
|
|
My mean is you can write empty bytes into target stream before compressing, not source stream.
|
|
|
|
|
Sorry for misunderstanding....
I'll check it out whether the method will seek to the Begin and overwrite my header...
|
|
|
|
|
Hello everyone,
Two questions related to meta data and attribute,
1.
.Net built-in and user defined attribute are both defined in meta data portion of assembly or not? In my past experience, I think method/class level attribute is only used to facilitate the method/class IL generation, and will not exist in final assembly file. Any comments?
2.
If .Net built-in and user defined attribute exist in the final meta data part of assembly, is it possible to use reflector to see them? (I have tried but can not find.)
thanks in advance,
George
|
|
|
|
|
Yes, they can be reflected. Recently I'm working on a project implementing plug-in architecture and this is the way I identify plug-ins.
|
|
|
|
|
Thanks natsuyaki,
1.
Sorry my English is not good. You mean both .Net built-in and user defined attribute exist in the final meta data part of assembly, even for the method level attribute?
2.
How do you find the final values? Using reflector tool or?
Reflector tool I mean,
http://www.aisto.com/roeder/dotnet/[^]
regards,
George
|
|
|
|
|
My English is not so good too...
1. class level attributes exist in meta data, method level unkonown...
2. Using Type.GetCustomAttribute() to get custom attribute at runtime.
Or the tool ILDasm in .NET SDK or others.
|
|
|
|
|
Great natsuyaki!
How to use ILDasm to read meta data and attributes? I only find IL for each method/class from this tool.
regards,
George
|
|
|
|
|
If there is a custom attribute. It displays ".custom instance void[xxx]xxxxxx.xxxxAtribute::cctor()=........."
|
|
|
|
|
Great natsuyaki!
How to identify which parts of IL code are dealing with attribute definition? Any fields or keywords in IL identify?
regards,
George
|
|
|
|
|
You can write and compile an assembly with custom and built-in class/method level attributes. See if they exist in meta data using ILDasm.
|
|
|
|
|
Thanks natsuyaki!
I think you monitor the attribute in IL using ILDasm tool, not the below tool, right?
http://www.aisto.com/roeder/dotnet/
(the tool has a confusing name relfector, which makes me confused in the discussion context)
regards,
George
|
|
|
|
|
but it's really using reflection.~
|
|
|
|
|
|
The following IL code is retrieved by ILDasm:
class with SerializableAttribute:
<br />
.class public auto ansi serializable beforefieldinit ClassLibrary2.Class1<br />
extends [mscorlib]System.Object<br />
{<br />
}
method with ObsoleteAttribute:
<br />
.method public hidebysig instance void s() cil managed<br />
{<br />
.custom instance void [mscorlib]System.ObsoleteAttribute::.ctor() = ( 01 00 00 00 ) <br />
.maxstack 8<br />
IL_0000: nop<br />
IL_0001: ret<br />
}
|
|
|
|
|
Thanks natsuyaki,
1.
It is great! Are there any tool for us to use to retrieve readable meta data and attribute information without using ILDasm tool?
2.
Generally speaking, from what pattern, could you identify a part of code in IL is dealing with attribute -- like the following code,
.custom instance void [mscorlib]System.ObsoleteAttribute::.ctor() = ( 01 00 00 00 )
regards,
George
|
|
|
|
|
1.
i don't really know, maybe the tool you mentioned can.
2.
I wrote a custom attribute PuginAttribute. All the plugins must add this attribute. So, I can get it at runtime by GetCustomAttribute(), if exists, that mean this is a plugin.
<br />
[Plugin(true)]<br />
public class SamplePlugin:IPlugin<br />
{<br />
.....<br />
....<br />
IL code would be displayed like this:
<br />
.custom instance void [XXXX]aaa.bbb.ccc.PluginAttribute::.ctor(bool) = ( 01 00 00 00 )<br />
|
|
|
|
|
Thanks natsuyaki,
1.
Looks like attribute will be treated as a private class in IL?
2.
I think not all built-in attributes will be left in final IL, what kinds of built-in attributes will be in final IL, could you list some please?
regards,
George
|
|
|
|
|
1.some like that
2.some attributes reprent for "mark",and some for "deal". That means, some attributes are use for comment the content, some for the compiler that the content will be processed by the mean mentioned in the attributes. So, some keep there and some disappeared.
This is my point of view. For the precise definition, please view msdn.
|
|
|
|
|
Thanks natsuyaki,
I agree with your points. Could you list some of the attribute names which do not disappear in IL please? Sorry, my knowledge of attribute is limited.
regards,
George
|
|
|
|
|
That's a big work to do....
You may be interested in this book: Applied .Net Attributes by Jason Bock
Sorry, here we go.
And this could also help:http://www.codeproject.com/KB/cs/attributes.aspx
modified on Monday, May 12, 2008 4:30 AM
|
|
|
|
|
Thanks natsuyaki,
The link you provided can not be opened, could you double check please?
regards,
George
|
|
|
|
|
byte[] CryptographicKey = Convert.FromBase64String(txtCK.Text);<br />
byte[] IVector = new byte[16];
Array.Copy(CryptographicKey, IVector, 16);
<br />
RijndaelManaged AES256 = new RijndaelManaged();<br />
AES256.KeySize = 256;<br />
AES256.Mode = CipherMode.CBC;<br />
ICryptoTransform Encryptor = AES256.CreateEncryptor(CryptographicKey, IVector);<br />
<br />
Ciphertext = new FileStream(txtOutputPath.Text, FileMode.Create, FileAccess.Write, FileShare.None);<br />
CryptoStream CStreamWriter = new CryptoStream(Ciphertext, Encryptor, CryptoStreamMode.Write);<br />
<br />
CStreamWriter.Write(Plaintext, 0, Plaintext.Length);
CStreamWriter.FlushFinalBlock();<br />
<br />
Ciphertext.Close();<br />
CStreamWriter.Close();
CStreamWriter.Write(Plaintext, 0, Plaintext.Length); //OUT OF MEMORY EXCEPTION HERE
The code works fine for files smaller than 150mb, but when I tried to encrypt a 300mb file. I got that exception. I have 3gb of ram and when I started the encryption, my usage is only at 30%.
What seems to be the problem?
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
|
|
|
|
|
Allocating a memory block of 300M at a time is not a good idea...
Try to split the file into smaller pieces and then encrypt.
|
|
|
|
|
Will the output still be the same?
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
|
|
|
|