|
thanks man, it helped cos i just didn't notice that folder when i copied the application.
tho i got another error which says that i have to install assembly stdole in GAC, but i don't want to bother you anymore, cos im sure im accapable of solving this problem on my own
|
|
|
|
|
Okey my problems are not really solved still.
I solved stdole.dll problem.
But now clr20r3 error came back and i can't run my setup in any computer either on the one that has office and on the one that has not.
But you already know the story of my problem from the first post and therefore i will not start repeating my self Smile and hope that some one has a solution for my problem.
|
|
|
|
|
I have an odd one - or odd to me at least.
public void Encrypt(Stream sIn, Stream sOut)
{
string Routine = "Encrypt: ";
if (key == null)
{
throw new Exception(Routine + EX_CRYPTO_NOKEY);
}
if (sIn.Length > int.MaxValue)
{
throw new Exception(Routine + EX_CRYPTO_TOOBIG);
}
sOut.Write(encAlg.IV, 0, encAlg.IV.Length);
CryptoStream encrypt = new CryptoStream(sOut, encAlg.CreateEncryptor(), CryptoStreamMode.Write);
byte[] abIn = new byte[sIn.Length];
sIn.Read(abIn, 0, (int) sIn.Length);
sIn.Close();
encrypt.Write(abIn, 0, abIn.Length);
encrypt.FlushFinalBlock();
encrypt.Close();
key.Reset();
}
public void Decrypt(Stream sIn, Stream sOut)
{
string Routine = "Decrypt: ";
if (key == null)
{
throw new Exception(Routine + EX_CRYPTO_NOKEY);
}
if (sIn.Length > int.MaxValue)
{
throw new Exception(Routine + EX_CRYPTO_TOOBIG);
}
int totalBytes = (int) sIn.Length;
=====>
=====> SEE BELOW
=====>
totalBytes -= encAlg.IV.Length;
CryptoStream decrypt = new CryptoStream(sOut, encAlg.CreateDecryptor(), CryptoStreamMode.Write);
byte[] abIn = new byte[totalBytes];
sIn.Read(abIn, 0, totalBytes);
sIn.Close();
decrypt.Write(abIn, 0, abIn.Length);
decrypt.Flush();
decrypt.Close();
key.Reset();
}
Replacing the bit marked ====> with the bits below
In Decrypt, if I try to read the IV from my encrypted file directly into encAlg.IV, the IV doesn't change.
sIn.Read(encAlg.IV, 0, encAlg.IV.Length);
If I read into a buffer first, then set the IV it works.
byte[] ab = new byte[encAlg.IV.Length];
sIn.Read(ab, 0, encAlg.IV.Length);
encAlg.IV = ab;
Any ideas?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
maybe that IV buffer is not the right size when you try to read directly. where as when using ab you have set the array size to be what is required... I don't know this for sure thou
for example, does the following work?...
encAlg.IV = new byte[encAlg.IV.Length];
sIn.Read(encAlg.IV, 0, encAlg.IV.Length);
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
No. the new encAlg.IV is still all zero after the read. (And predicably enough the decrypt yields garbage as you would expect)
Read into a buffer, set the encAlg.IV to the buffer and the decrypt works perfect. Weird...
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I am working on a program to aid in troubleshooting a clinical application we use in house. The application is a .NET program that runs in a terminal server environment. I would like to return a stack trace whenever a user presses a "help button." This button will take a screenshot and return a list of all running processes. I would also like it to return a stack trace of any of the LTCDB (the application) processes running. Is there a way of doing this?
Chris Sims
Senior Applications Specialist
NHS Management, LLC.
|
|
|
|
|
Hi All ,
I have 50,000 entries on my Sql 2005 Table.I would like to know the first time each distinct objects gets in to my table.
Lets say object1 has 10 records on my table at diffrent date ,object2 gas 100 records on the table,object3 has 500 records in the table registered at different date.
I would like to reterive each objects with there first entry only,how would i do it?
Please advice.
THank you all
|
|
|
|
|
|
It's going to be something like
SELECT objectName, MIN(objectDateInserted) FROM yourTable GROUP BY objectName
where objectName is the column containing 'object1', 'object2' etc. and objectDateInsert is the column containing insertion dates of the individual records. MIN selects the first insertion.
Others will correct me. But yeah, it is a wrong forum.
H.
|
|
|
|
|
Many thanks for your response.Its Much appreciated.
The problem i have is there is another column in my select statement.
SELECT objectName, MIN(objectDateInserted),SO_Name FROM yourTable GROUP BY objectName
Then It gives me to diffrent entry for diffrent SO_name for the same object1. However ,what i want is the minimum of the three all those in Time.
Please advice
Thank you once again.
|
|
|
|
|
I understand what you mean but unfortunatelly - I don't know. It doesn't seem like a difficult problem so maybe if you try your luck in some SQL/Database forum, you'll get the answer. I'm really not much of a database expert.
Sorry, H.
|
|
|
|
|
Hi i have me one maghalha dar mored ((araye) 1,2,3 body)
pleas help me
thanks
|
|
|
|
|
++ OUT OF CHEESE ERROR ++ REDO FROM START ++
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Ah, HEX is here!
(Does this herald the coming of the Apocralypse?)
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
|
Use a list of araye{1,2,3,body}, thats what you need.
|
|
|
|
|
Hello frnds,
I am developing installer to deploy my application for that i am using VS 2005 Setup and deployment fascility.
I have my own desinged window form having a textbox and button for Browsing the folder.
the instance of above mentioned form is created inside install method of installer.
whenever i start installing my msi file i am getting the above form
containing textbox and browse button.
On click of browse button i have written folderBrowserDialog .showDialog
but Folder Browser Dialog does not display dialog window.
thanks in advance..
|
|
|
|
|
Hi there,
Well I think I've passed by this problem before,
As far as I know , the folderBrowserDialog is treated as an UI object , so you can't modify it from any function other than the main thread ( on the thread that created the UI element, which is the thread of your msi in your case )
In order to do this, the Control class (folderBrowserDialog) provides the Invoke method, which will take a delegate and execute it on the thread that the UI element was created on.
In order to use this:
1- one must declare a function that performs the UI operation.
2- create a method that will call the ShowDialog on the folderBrowserDialog object.
that's all , I hope this can be the solution for your problem as it was for me.
Good LUCK
|
|
|
|
|
Thanks for your reply i will check it.
|
|
|
|
|
I have this code for encryption-decryption some data, when i run it, it makes the exception: "Padding is invalid and cannot be removed"
I did everything i found in google or forums but none helped me.
I appreciate any ideas! Please help me!
This is the Code:
using System;<br />
using System.IO;<br />
using System.Text;<br />
using System.Security.Cryptography;<br />
<br />
<br />
public sealed class Cryption<br />
{<br />
private RijndaelManaged Algorithm;<br />
private MemoryStream memStream;<br />
private ICryptoTransform EncryptorDecryptor;<br />
private CryptoStream crStream;<br />
private StreamWriter strWriter;<br />
private StreamReader strReader;<br />
<br />
private string m_key;<br />
private string m_iv;<br />
<br />
private byte[] key;<br />
private byte[] iv;<br />
<br />
private string pwd_str;<br />
private byte[] pwd_byte;<br />
<br />
public Cryption(string key_val, string iv_val)<br />
{<br />
key = new byte[32];<br />
iv = new byte[32];<br />
<br />
int i;<br />
m_key = key_val;<br />
m_iv = iv_val;<br />
<br />
for(i=0;i<m_key.length;i++)><br />
{<br />
key[i] = Convert.ToByte(m_key[i]);<br />
}<br />
for(i=0;i<m_iv.length;i++)><br />
{<br />
iv[i] = Convert.ToByte(m_iv[i]);<br />
}<br />
<br />
}<br />
<br />
<br />
public string Encrypt(string s)<br />
{<br />
Algorithm = new RijndaelManaged();<br />
<br />
Algorithm.BlockSize = 256;<br />
Algorithm.KeySize = 256;<br />
Algorithm.Padding = PaddingMode.PKCS7;<br />
<br />
memStream = new MemoryStream();<br />
<br />
EncryptorDecryptor = Algorithm.CreateEncryptor(key,iv);<br />
<br />
crStream = new CryptoStream(memStream, EncryptorDecryptor, CryptoStreamMode.Write);<br />
<br />
strWriter = new StreamWriter(crStream);<br />
<br />
strWriter.Write(s);<br />
<br />
strWriter.Flush();<br />
crStream.FlushFinalBlock();<br />
<br />
pwd_byte = new byte[memStream.Length];<br />
memStream.Position = 0;<br />
memStream.Read(pwd_byte,0,(int)pwd_byte.Length);<br />
<br />
pwd_str= new UnicodeEncoding().GetString(pwd_byte); <br />
return pwd_str;<br />
}<br />
<br />
<br />
public string Decrypt(string s)<br />
{<br />
Algorithm = new RijndaelManaged();<br />
<br />
Algorithm.BlockSize = 256;<br />
Algorithm.KeySize = 256;<br />
<br />
MemoryStream memStream = new MemoryStream(new UnicodeEncoding().GetBytes(s));<br />
<br />
ICryptoTransform EncryptorDecryptor = Algorithm.CreateDecryptor(key,iv);<br />
memStream.Position = 0;<br />
CryptoStream crStream = new CryptoStream(memStream, EncryptorDecryptor, CryptoStreamMode.Read);<br />
strReader = new StreamReader(crStream);<br />
<br />
return strReader.ReadToEnd();<br />
}<br />
<br />
}<br />
|
|
|
|
|
Post the exception type and full stack trace. Also post any other details on the exception and any inner exceptions.
Simon
|
|
|
|
|
here is the stack trace:
System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed.<br />
at System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast)<br />
at System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)<br />
at System.Security.Cryptography.CryptoStream.Read(Byte[] buffer, Int32 offset, Int32 count)<br />
at System.IO.StreamReader.ReadBuffer()<br />
at System.IO.StreamReader.ReadToEnd()<br />
at Cryptography.Cryption.Decrypt(String s) in F:\Comp\Crypt\Cryption.cs:line 96<br />
at CryptSample.Form1.btnDecrypt_Click(Object sender, EventArgs e) in F:\Comp\Crypt\Form1.cs:line 230<br />
I think it's somehow about the streamreader/writer (Am I right?) but i don't know how to fix it!!!
anyway THANK YOU for your attention.
Roshanak
|
|
|
|
|
The 3 most likely reasons for this error:
1) You are using different padding schemes when encrypting and decrypting.
2) You are using different encoding formats for encrypting and decrypting.
3) When encrypting you haven't properly flushed the stream out to the file.
Looking at your code it looks like you set the padding to pkcs7 when encrypting , but don't do the same when decrypting.
Simon
|
|
|
|
|
I set the padding to pkcs7 in both encryption and decryption and i build the project again but it still makes the exception.
About encoding format, i'm using unicodeEncoding in both,
you can see in encryption:
pwd_str= new UnicodeEncoding().GetString(pwd_byte);<br />
return pwd_str;
and in decryption:
MemoryStream memStream = new MemoryStream(new UnicodeEncoding().GetBytes(s));
and for the streams:
<br />
strWriter.Flush();<br />
crStream.FlushFinalBlock();
i don't know how else i can flush them!!!
Again THANKS
Roshanak
|
|
|
|
|
I think the problem is the way you are reading data out of the memory stream. Use a stream reader instead of getting the bytes and doing unicode encoding. I suspect that is screwing things up. Then use a stream writer to put the string back into the memory stream when decrypting. (This works fine on my PC if I make that change)
Roshanakak wrote: i don't know how else i can flush them!!!
You're not calling dispose no any of your streams. You should be using 'using' to properly dispose of the streams. Anything that has a dispose method should be created within a using block (or if not, make sure you call Dispose() in some other way - like in a finally block) Like this:
using (MemoryStream memStream = new MemoryStream())
{
using (ICryptoTransform EncryptorDecryptor = Algorithm.CreateEncryptor(key, iv))
{
using (CryptoStream crStream = new CryptoStream(memStream, EncryptorDecryptor, CryptoStreamMode.Write))
{
using (StreamWriter strWriter = new StreamWriter(crStream))
{
strWriter.Write(s);
strWriter.Flush();
crStream.FlushFinalBlock();
}
}
}
}
Also, you're using a bunch of member variables on the class that your just overwriting when you decrypt. Get rid of these and make them local variables in the method. That will prevent any crossover or leak of setup from one method to the other.
Simon
|
|
|
|
|