|
The retrieve code not included there
|
|
|
|
|
only two letters away from being an asset
|
|
|
|
|
I have created a addin for outlook 2003 using c# and installing using setup project. How can i prompt user to close outlook if it is open during install/uninstall?
In setup project how can i add this condition?
|
|
|
|
|
You can get all processes by some name:
<br />
Process [] localByName = Process.GetProcessesByName("notepad");<br />
But it is not a strong solution. User can modify name of a file executes an outlook so you didn't get it
|
|
|
|
|
I've noticed a odd problem when using a class that implements IList<T> with a BindingSource. I've managed to reproduce the problem with some simple classes. I have a class called BaseClass and several classes that derive from BaseClass called DerivedClass1, DerivedClass2 and DerivedClass3.
Now I create a class to act as a collection of BaseClass objects called BaseClassCollection. BaseClassCollection implements IList<T> and basically just wraps a List<BaseClass> at this point. At this point everything works fine and I can populate the BaseClassCollection with objects of type DerivedClass1, DerivedClass2 and DerivedClass3 to create a heterogenous collection.
Now the problem comes when I try and use BaseClassCollection as a DataSource for a BindingSource. I create a form with a ListBox control with it's DataSource set to a BindingSource. I then set my BindingSource to bind to an empty BaseClassCollection. Then I add three buttons that will add either a DerivedClass1, DerivedClass2 or a DerivedClass3 object to the collection and refreshes the BindingSource. If I add several objects of the same type then I have no problem, but as soon as I try to add a object of a different class I get an exception:
The value "BindingTest.Derived2" is not of type "BindingTest.Derived1" and cannot be used in this generic collection.
Parameter name: value
It seems that when you set the DataSource of the BindingSource to an IList<T> it looks at the first item in the list (let's say it's a DerivedClass1) and assumes that the list is a DerivedClass1 list and won't let you add anything that isn't a DerivedClass1. What it should do is recognize that it's an IList<baseclass> and assume we have a list of BaseClass and thus allow the addition of any class derived from BaseClass. Oddly enough, if I make my BaseClassCollection inherit from List<BaseClass> instead or implementing IList<BaseClass> then it works as expected, but I lose the ability to control the implemenation of the list.
Does anybody know what is happening here? How do I make the BindingSource realize that it's dealing with a collection of BaseClass?
-- modified at 21:21 Friday 8th June, 2007
Fixed by < and > which completely changed the meaning of the question
|
|
|
|
|
By comparing the IList<T> interface with the List<T> class I noticed that one difference is that List<T> implements IList as well as IList<T>. Implementing IList in addition to IList<T> in my class seemed to fix the problem, although I have no idea why?
|
|
|
|
|
I am currently developing a Form that will scan a plugins directory and load any dll files that have a baseType of "MadPages.PageBase"
For proof of concept, I created a Control that extended the PageBase class. The form application found the dll file and loaded it into the application as planned.
My new problem is this. I have a new project in the solution named ProjectA. ProjectA is another control library that extends the PageBase class. ProjectA has a reference to another project which I called ProjectB. When my form application finds the DLL file for ProjectA, I do a foreach loop on the dll file's GetTypes().
This of course now comes up with 2 types...PageBase and ProjectB. When I try to dynamically load the Type PageBase into a local PageBase variable, I get an exception stating that it cannot find the dll for ProjectB. If I add a reference to my main form's project (pointing to to ProjectB), the application can load ProjectA. I know I must be doing something wrong.
The point of having these plugins was so I don't have to touch the main form's project when I want to extend it. Please let me know what I am doing wrong. Here is the code on how i'm loading my dll files from the plugin-dir:
Assembly asm= Assembly.LoadFile(path);
foreach (Type t in asm.GetTypes())
{
if (t.BaseType.ToString() == "MadPages.PageBase")
{
return (PageBase)t.GetConstructors()[0].Invoke(new object[] { });
}
}
There is only one constructor for the PageBase class. Thanks!
|
|
|
|
|
One more little thing I found out while de-bugging. If I step through the constructor for ProjectA, as soon as it tries to make a call to ProjectB it bombs meaning that it cannot find the file.
When I compile ProjectA and run it, everything is fine. The ProjectB's dll file is in the same folder as ProjectA's. I am copying these dll files over to a plugins directory for the main application. Both dll files are once again in the same folder but it looks like once I copy both of them to another directory, ProjectA doesn't find the dll for ProjectB. Someone wanna school me on this awful Friday?
|
|
|
|
|
|
Worked! I owe you a beer good sir. Thanks a lot!
|
|
|
|
|
Make it a Guiness
only two letters away from being an asset
|
|
|
|
|
Hi all,
going nuts... i placed a windows media player on my form (tried the 6.4 version and version 10) and like to play a mkv file (720p x264).
I can play the mkv in the old media player that comes with xp (C:\Program Files\Windows Media Player\mplayer2.exe) without any problems.
The embedded player tries to connect to the internet, probably to find a codec.
It only plays the sound.
Does anyone know how i can make the mkv play in my form ?
thanx a lot.
|
|
|
|
|
Matroska (Mkv) is just a container (like avi), so the file format says nothing about the codec used. Try installing CCCP, and it will probably work.
Standards are great! Everybody should have one!
|
|
|
|
|
i don't want to install other codecs, since it works in the standard windows mediaplayer, it should work in my embedded player too.
|
|
|
|
|
Hai Everybody,
I want to encrypt the user name and password given by the user separately and i have to store the encrypted content in sql server. yesterday our forum members suggested me to use the SHA256 algorithm so that i referred one article in our forum but it encrypts and decrypts some file contents.
I felt very difficult to understand also.
So can anyone suggest me some other simple and strong algorithm.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
The System.Security.Cryptographic namespace within the Microsoft .NET Framework provides a variety of tools to aid in encryption and decryption. The CryptoStream class is used here to demonstrate the encryption and decryption with System.Security.Cryptographic.SymmetricAlgorithm.
For Details[^]
Regards,
Satips.
|
|
|
|
|
I cant help you with SHA256, but maybe another solution is acceptable for you.
I'am using the MD5, but this is only a unidirectional encryption.
I show a dialog to enter a password and encrypt the password via MD5. The encrypted result will then be stored in a database.
When the user logs on again, he must enter the password, which will be encrypted again with MD5.
To verify if the password is correct i compare the encryption stored in the database, with the new encryption.
To get the MD5 encryption do the following:
public static string StringToMd5(string text)
{
byte[] data = System.Text.Encoding.Unicode.GetBytes(text);
System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] result = md5.ComputeHash(data);
System.Text.StringBuilder s = new System.Text.StringBuilder();
foreach (byte b in result)
{
s.Append(b.ToString("x2").ToLower());
}
return s.ToString();
}
may be it suits you...
greets Snow
|
|
|
|
|
Just as a note MD5 is considered insecure now and it's recommended to change to the SHA-1 hash instead.
|
|
|
|
|
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.Security.Cryptography;<br />
<br />
namespace Helper.Crypto<br />
{<br />
public class HashMethods<br />
{<br />
public static string GenerateSalt()<br />
{<br />
byte[] Salt = new byte[32];<br />
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();<br />
rng.GetNonZeroBytes(Salt);<br />
return Encoding.UTF8.GetString(Salt);<br />
}<br />
public static string Hash(string text,string saltString)<br />
{<br />
string SaltedString = text + saltString;<br />
byte[] SaltedText = Encoding.UTF8.GetBytes(SaltedString);<br />
HashAlgorithm hash = new SHA512Managed();<br />
byte[] hashBytes = hash.ComputeHash(SaltedText);<br />
return Convert.ToBase64String(hashBytes);<br />
}<br />
}<br />
}
I store both the salt and the hashed PWD+Salt in a DB.
When a client tries to log in the server gives it the salt and the client adds the salt to the username and hashes. pass the hashed password up to the server and compare with the value stored in the DB.
This way you never know the user's password.
HTH
Russ
|
|
|
|
|
Does anybody know how I can get the SQL Connection DialogBox to show up in C#?
You know, the one that comes up when you open SQL query analyzer. I think that I need to use Microsoft.Data.ConnectionUI which I need to install another SDK to use. Does anybody know which SDK this is?
Any help would be appreciated
Thanks
There are 10 types of people in the world, those who understand binary and those who dont.
|
|
|
|
|
I'm looking for a way to represent an instantiated class as a byt array (and populate an instantiated class frm a byte array. I was hoping that [Serializable] would be the magic bullet but it seems I was wrong - or do I just not understand how to use [Serializable] properly?
Let's say I have:
public class myClass
{
public byte myByte1;
public byte myByte2;
public ushort myUshort1;
public ushort myUshort2;
public myClass()
{
this.myByte1 = 0x01;
this.myByte2 = 0x02;
this.myUshort1 = 0x0304;
this.myUshort2 = 0x0506;
}
}
Now, if I instantiate this class with myClass myInstance = new myClass() the member variales will hold the values as defined by the constructor. I'd like to be able to view the contents of the class as an array of bytes (ie. {0x01, 0x02, 0x03, 0x04, 0x05, 0x06} ).
So I was thinking that if the class is serializable and I write the seraialized stream to a byte array (or write a byte array to the associated stream) I'd be able to pull it off, something like this:
MemoryStream memStream = new MemoryStream();
BinaryFormatter binFormatter = new BinaryFormatter();
binFormatter.Serialize(memStream, myInstance);
byte[] myBytes = memStream.ToArray();
But myBytes is 183 bytes in size (as opposed to the expected 6 bytes) once this is finished and the contents of myBytes makes no sense to me whatsoever.
Am I on completely the wrong track here or is there hope?
|
|
|
|
|
Here are many additional information is added with serialization like assembly name, version, class name, structure, ........
All this information is necessary to deserialize this object
|
|
|
|
|
Aha, that makes sense. So does that mean that [Serializable] would not be the proper route then?
Would you have any other suggestions?
|
|
|
|
|
Dewald wrote: Aha, that makes sense. So does that mean that [Serializable] would not be the proper route then?
Yes, if the array size is not critical.
If critical you have to realize you own convertion like:
<br />
public class myClass<br />
{<br />
public byte myByte1;<br />
public byte myByte2;<br />
public ushort myUshort1;<br />
public ushort myUshort2;<br />
<br />
public myClass()<br />
{<br />
<br />
}<br />
<br />
public static byte[] ToByteArray(myClass value)<br />
{<br />
byte[] result = new byte[6];<br />
<br />
result[0] = value.myByte1;<br />
result[1] = value.myByte2;<br />
unchecked<br />
{<br />
result[2] = (byte)(value.myUshort1 / 256);<br />
result[3] = (byte)(value.myUshort1 - result[2] * 256);<br />
result[4] = (byte)(value.myUshort2 / 256);<br />
result[5] = (byte)(value.myUshort2 - result[4] * 256);<br />
}<br />
<br />
return result;<br />
}<br />
<br />
public static myClass FromByteArray(byte[] array)<br />
{<br />
myClass result = new myClass();<br />
<br />
result.myByte1 = array[0];<br />
result.myByte2 = array[1];<br />
result.myUshort1 = (ushort)(array[2] * 256 + array[3]);<br />
result.myUshort2 = (ushort)(array[4] * 256 + array[5]);<br />
<br />
return result;<br />
}<br />
}<br />
P.S. usort is 16-bit type so we need to store it into two bytes.
|
|
|
|
|
Yip, this is exactly what I've been doing up until now but I was just hoping that there wuld be a more elegant sollution. The thing is that I have various classes that I'd like to be able to pack into byte arrays (basically the classes are just messages that I need to transmit and receive over a TCP socket).
I was hoping that I could write a base class that provides a method of packing the class into an array and then derrive all the other classes from that class. That way I wouldn't have to implement a huge amount of tedious code to pack every individual member variable of the class into the array.
|
|
|
|