|
Wow ... thanks for this ...
I just tried this code and I'm getting a StackOverflowException on:
this.ThreadCompleted.GetInvocationList();
If I put a breakpoint on this line and look at the ThreadCompleted object the _invocationList has a count of 0 even though I know there is at least one subscription to the event ...
|
|
|
|
|
If you email me your solution, i can assist you further.
|
|
|
|
|
Thanks for this offer Fayu, where should I send the solution?
Thanks,
|
|
|
|
|
Check your email. I sent you my e-mail address.
|
|
|
|
|
I looked at your code and it seems like you are using WPF. This changes things. Multithreading is a little different in WPF. The code below should resolve your issue:
if (ThreadCompleted != null)
{
Window caller = (Window)this.ThreadCompleted.Target;
if (!caller.Dispatcher.CheckAccess())
{
ThreadCompleterEventHandler del = new ThreadCompleterEventHandler(OnThreadCompleted);
object[] args = { sender, e };
caller.Dispatcher.Invoke(del, args);
return;
}
this.ThreadCompleted(sender, e);
}
Hope this helps.
modified on Friday, March 20, 2009 8:53 AM
|
|
|
|
|
hello ,
i would like to use Rejex to validate a user name.
my user name rules are as follows:
1. first character is a letter : a-z, A-Z
2. other characters can be letters , numbers and _
3. a space can be used only once.
i tried this one but it didnt work :
Boolean Result = false;
string PatternString = @"[_-zA-Z0-9\s]$";
Result = Regex.Match(UserNameString, PatternString).Success;
tnx in advance,
avi
|
|
|
|
|
im not 100% but try...
"[a-zA-z][a-zA-z0-9_]*[ ]?[a-zA-Z0-9_]$"
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
hi,
its semi working.
there is a problem with the initial value.
i can enter the following string: ,jukj
and it will also be successfull.
tnx,
avi
|
|
|
|
|
oh yes, you need to make it specify to use the start of the string, i think ^ does that job...
"^[a-zA-z][a-zA-z0-9_]*[ ]?[a-zA-Z0-9_]$"
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
You also probably need another asterisk in there right before the $. Otherwise it'll only allow one more character after the optional space.
|
|
|
|
|
cool
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
thanks musefan , it works fine
|
|
|
|
|
shabya wrote: 1. first character is a letter : a-z, A-Z
2. other characters can be letters , numbers and _
3. a space can be used only once.
Based on that, I suggest a little modification to musefan's regex.
"^[a-zA-z][a-zA-z0-9_]*\s?[a-zA-Z0-9_]*$"
Eslam Afifi
|
|
|
|
|
kool , it works
here's an email "Rejexianization" i found , also works well
string PatternString =
@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
@"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
@".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
|
|
|
|
|
Hi Everyone
I have a class which contains a load of data for my application which is to be saved using serialization. The problem is, I have a couple of hash tables in there which automatically impletents iDictionary. Serialization does not like this. Is there a way of making this work? or does anybody have any other ideas on what I could use to store value pairs of data that does not implement iDictionary?
Thank you
oooo, the Jedi's will feel this one....
|
|
|
|
|
do googling!!!!!!!
there is no direct way to do this but yes workaround is there and available on internet
|
|
|
|
|
OK!!! let me provide you with the code snippest
Serialization unfortunately doesnot support dictionary.we have to write some rutines to workaround for it
in following code I have added a dedicated property for serializing my dictionary
Note:This property is of no use in client classes use only for serialization/deserialization
class ClassToSerialize
{
private Dictionary<string,string> dict=new Dictionary<string,string>();
[XmlArray("Name")]
[XmlArrayItem("ItemName", Type = typeof(DictionaryEntry))]
public DictionaryEntry[] _signalsNotToBeVerified
{
get
{
DictionaryEntry[] ret = new DictionaryEntry[this.dict.Count];
int index = 0;
DictionaryEntry de;
foreach (KeyValuePair<string,> dictEntries in this.dict)
{
de = new DictionaryEntry();
de.Key = dict.Key;
de.Value = dict.Value;
ret[index] = de;
index++;
}
return ret;
}
set
{
this.dict.Clear();
for (int index = 0; index < value.Length; index++)
{
this.dict.Add((string)value[index].Key, (string)value[index].Value);
}
}
}
Enjoy!!!!!!!!!!!
|
|
|
|
|
Thats a huge help. Thank you.
oooo, the Jedi's will feel this one....
|
|
|
|
|
|
Hi All!!
In code below, i'm encrypting bitmap(24-bit) image, accessed from ms-access database. Here is my code:
private void button1_Click(object sender, System.EventArgs e)
{
string connString = "provider=Microsoft.Jet.OLEDB.4.0;" + @"data
source=D:\\practiceproject\practice.mdb";
OleDbConnection connection = new OleDbConnection(connString);
string commandString = "Select Image from readImage where ID=1";
OleDbCommand cmd = new OleDbCommand(commandString,connection);
byte[] toEncrypt = new byte[120154];
connection.Open();
toEncrypt = (Byte[]) cmd.ExecuteScalar();
connection.Close();
RSAParameters rsaPubParams;
RSAParameters rsaPrivateParams;
RSACryptoServiceProvider rsaCSP = new RSACryptoServiceProvider();
rsaPrivateParams = rsaCSP.ExportParameters(true);
rsaPubParams = rsaCSP.ExportParameters(false);
rsaCSP.ImportParameters(rsaPubParams);
byte[] encrypted = new byte[130000];
encrypted = rsaCSP.Encrypt(toEncrypt, false);
}
But i get
Bad Length error at line
encrypted = rsaCSP.Encrypt(toEncrypt, false);
Please help me to resolve this problem!!!
modified on Thursday, March 19, 2009 11:35 AM
|
|
|
|
|
the way you've posted your code makes it very hard to read... please unbold and use a code block then people will look at it more and not jump it.
|
|
|
|
|
I have not done anything with encryption for a long time. So this is not guaranteed to work.
I think your problem is in the declaration of encrypted .
Instead of:
byte[] encrypted = new byte[130000];
encrypted = rsaCSP.Encrypt(toEncrypt, false);
try:
byte[] encrypted = rsaCSP.Encrypt(toEncrypt, false);
After all you do not know in advance the length of the byte-array thet encrypt will return, so why set a length in the declaration.
Good luck!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I tried that but again
Bad Length error is at:
byte[] encrypted = rsaCSP.Encrypt(toEncrypt, false);
Please help me out...
|
|
|
|
|
OK.
After a little research. I think the problem might lie in the length of the input.
From a little reading it seems that RSACryptoServiceProvider was designed for encrypting cryptographic keys, it gets a bit upset if you ask it to do too much work. A bit like me.
There is quite a bit on the web about this problem, and I would suggest that you do a little more research. I Googled "RSACryptoServiceProvider Bad Length", and if you do the same, you might find a solution, but I doubt it.
Choose another CryptoServiceProvider , if you are allowed to. I think that will make your life a whole lot easier.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Henry!!
Thanks for your help...I searched that too...None of the article contains image encryption through RSACryptoserviceprovider. other CryptoServiceProviders are used...
|
|
|
|