|
though I have found the chevron implementation to be quite buggy.
Wow, you weren't kidding. I got an exception after every other sort. It did exactly what I wanted though; hope they look into making it a bit more stable.
|
|
|
|
|
I was wondering if there is any (preferably relatively straighforward) way for a method in C# to obtain the object which made the call. For example...
namespace Example
{
public class A
{
private B b;
public A()
{
b = new B();
b.Call();
}
}
public class B
{
public B()
{
}
public void Call()
{
object caller = null;
}
}
}
I hope this makes some sense. Any hints / tips are much appreciated.
--
The Last Bastion
|
|
|
|
|
|
Have a look at the stack trace objects in the debugging namespace, cant remember offhand where it is (not on a .NET Pc at the moment!) System.Diagnostics might be the one. Not 100% sure if it returns the object, or just a list of methods called.
Cheers, James
James Simpson
Web Developer
imebgo@hotmail.com
|
|
|
|
|
|
leppie wrote:
hey where is the object?
There isn't one, also what would you do if the caller was a static method? In that case there is no object reference that is doing the calling.
AFAIK, the best you can hope for is to get the class/struct name and possibly get the Type object representing it.
James
At Jethro Tull's August 28, 2003 concert Ian Anderson mentioned that the group would be performing a medley of title tracks. The songs were "Songs from the Wood", "Too Old to Rock and Roll; Too Young to Die"; and from the Heavy Horses album, "Stairway to Heaven".
|
|
|
|
|
My article on custom trace listeners has a decent write-up on this:
TraceListeners and Reflection
Towards the end there's a section on "StackFrame and StackTrace", with some example code.
Jerry Dennany
|
|
|
|
|
Hi,
I am having a lot of problems of calling an unmanaged DLL.
The parameters it is expecting are two structures, (one for input and the other is output). When I run it, the output structure is not being populated.
I have been using the marshalAs for the datatypes,
[MarshalAs(UnmanagedType.LPStr, SizeConst=1)]
public string Name;
Does anyone know of good examples where they are passing classes or structures. Also I think the API needs a fixed structure. Does the sizeConst in the attribute handle this?
|
|
|
|
|
Hi Everyone,
I'm on a mission to learn and successfully utilize the most popular of the software design patterns out there today.
I don't come from an OO background but after using .net for a couple of years I'm rougly getting into shape and I now really need to solidify my knowledge of design patterns.
I've found some explanations on the web and even bought a book called "C# Design Patterns" by James W. Cooper but found the examples poorly explained, written, and drawn out. This book is awful and has not helped me so far. MSDN examples have been overly simplified and really do not provide any useful code samples that would apply to everyday development. Through the course of many of my projects I have found that many times I was using some of the patterns in one way or another unwittingly, in other words; they just came naturally.
Can anyone provide me with some links/books/resources on how to better familiarize myself w/ software design patterns? Are they even useful? Should I bother? I would prefer samples in C# but any good info is welcome.
Most appreciated, thanks!
****************************
Melodious Funk
|
|
|
|
|
http://www.dofactory.com/Patterns/Patterns.aspx
|
|
|
|
|
|
I'm trying to open and query an AS400/DB2 Database via OleDB. I can do this fine via ODBC, but when I try to use Ole DB, I get the following error:
OleDbException: Multiple-step OLE DB operation generated errors.
My code and query is quite simple, and the exception is caused on the OleDbConnection.Open() method. Could anyone shed some light on what this may mean?
Here's my code:
string source = ("Provider=IBMDA400;Data Source=10.10.10.1;USERID=myusername; Password=mypassword;";
OleDbConnection con = new OleDbConnection(source);
try
{
con.Open();
}
catch (Exception a)
{
MessageBox.Show(a.ToString());
return;
}
Thanks in advance.
|
|
|
|
|
Hi dear,
How can I convert the following VB Script to C# ?
Function En2Fr (sStr)<br />
<br />
Dim nLen, i, ch, sFrStr<br />
<br />
nLen = Len(sStr)<br />
<br />
if nLen = 0 OR IsNull(nLen) then<br />
En2Fr = sStr<br />
Exit Function <br />
end if<br />
<br />
sFrStr = ""<br />
<br />
for i = 1 to nLen<br />
ch = Mid(sStr, i, 1)<br />
if 48 <= Asc(ch) AND Asc(ch) <= 57 then<br />
ch = ChrW(Asc(ch) + 1728)<br />
end if<br />
sFrStr = sFrStr + ch<br />
next<br />
<br />
En2Fr = sFrStr<br />
<br />
End Function<br />
Thank you in advance.
|
|
|
|
|
Have you tried doing the conversion yourself, or are you just too lazy? If you have tried it, which part are you specifically having problems with?
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
I have a problem to get the ascii characters in fact i have a problem with converting these lines
<br />
if 48 <= Asc(ch) AND Asc(ch) <= 57 then<br />
ch = ChrW(Asc(ch) + 1728)<br />
|
|
|
|
|
You can convert "Asc(ch)" to "(int)ch" or
System.Text.ASCIIEncoding.ASCII.GetBytes(new char[1]{'c'});
if ( (48 <= ((int)ch)) && (((int)ch) <= 57) ){
ch = (char) (((int)ch) + 1728);
}
|
|
|
|
|
|
The AscW and ChrW functions are directly equivalent to casting between a char and an int ;
To correctly duplicate the Chr and Asc functions needs a bit more work. You could add a reference to the Microsoft.VisualBasic assembly, and use the static methods of the Strings class. Alternatively, you can use:
public static char Chr(int i)
{
if (0 <= i && i <= 127) return (char)i;
if (i < -0x8000 || i > 0xFFFF) throw new ArgumentOutOfRangeException();
System.Text.Encoding enc = System.Text.Encoding.Default;
if (enc.GetMaxByteCount(1) == 1 && (i < 0 || i > 0xFF))
throw new ArgumentOutOfRangeException();
System.Text.Decoder dec = enc.GetDecoder();
byte[] b;
char[] c;
if (0 <= i && i <= 0xFF)
{
b = new byte[1];
b[0] = checked((byte) (i & 0xFF));
c = new char[1];
dec.GetChars(b, 0, 1, c, 0);
}
else
{
b = new byte[2];
b[0] = checked((byte) ((i >> 8) & 0xFF));
b[1] = checked((byte) (i & 0xFF));
c = new char[1];
dec.GetChars(b, 0, 2, c, 0);
}
return c[0];
}
public static int Asc(char ch)
{
int i = (int)ch;
if (i < 128) return i;
System.Text.Encoding enc = System.Text.Encoding.Default;
char[] c = new char[] {ch};
byte[] b = enc.GetBytes(c);
if (b.Length == 2 && BitConverter.IsLittleEndian)
{
byte t = b[0];
b[0] = b[1];
b[1] = t;
}
if (b.Length == 2)
return BitConverter.ToInt16(b,0);
else
return b[0];
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
|
"Hi dear"
|
|
|
|
|
Hi, trying to encrypt something using RSAServiceProvide. I have two problems.
1. Bad data when decrypting.
(1) In prototype, RSA_Server instance in decrypting side and encrypting side is the same instance. Of course, this will change later.
RSAServiceProvider RSA_Server;
(2) On encrypting side:
RSA_Server = new RSACryptoServiceProvider();
encryptedbuffer = RSA_Server.Encrypt(
databuffer,
false);
NOTE: At first I was suspecting that databuffer is than 5 bytes. But I get same problem after I trimmed databuffer down to one bytes. Anyway, here's quote from MSDN:
"The length of the rgb parameter is greater than the maximum allowed length. If the fOAEP parameter is false and the encryption is performed on a computer with the high encryption pack installed, the maximum length of the rgb parameter is 16 bytes. If the high encryption pack is not installed, the maximum length of the rgb parameter is 5 bytes."
(3) On decrypting side:
plaintext = RSA_Server.Decrypt(encryptedbuffer, false);
2. How can I retrieve private key from RSAParameters instance? I need to "publish" my public key - not the entire RSAParameters. Here's code from MSDN:
//Good. PublicKey and "Exponent" are both byte array.
byte[] PublicKey = {214,46,220,83,160,73,40,39,201,155,19,202,3,11,191,178,56,
74,90,36,248,103,18,144,170,163,145,87,54,61,34,220,222,
207,137,149,173,14,92,120,206,222,158,28,40,24,30,16,175,
108,128,35,230,118,40,121,113,125,216,130,11,24,90,48,194,
240,105,44,76,34,57,249,228,125,80,38,9,136,29,117,207,139,
168,181,85,137,126,10,126,242,120,247,121,8,100,12,201,171,
38,226,193,180,190,117,177,87,143,242,213,11,44,180,113,93,
106,99,179,68,175,211,164,116,64,148,226,254,172,147};
byte[] Exponent = {1,0,1};
//Create a new instance of RSACryptoServiceProvider.
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
//Create a new instance of RSAParameters.
RSAParameters RSAKeyInfo = new RSAParameters();
//Set RSAKeyInfo to the public key values.
RSAKeyInfo.Modulus = PublicKey; <--- OKAY, that's your public key.
RSAKeyInfo.Exponent = Exponent; <--- what da? Is this your private key?
//Import key parameters into RSA.
RSA.ImportParameters(RSAKeyInfo);
I need to pass encrypted data + RSA public key to decrypting side.
Thanks.
|
|
|
|
|
hope someone is reading the thread.
QUESTION 3:
Is RSAParameters serializable? can I send it via tcp channel as byte array?
Thanks.
|
|
|
|
|
Hi,
Can you tell me that how can I prevent a C++ class from being inherited by any other class. In C#, we have the keyword "sealed" and "final" in Java.
Do we have any keyword in C++ to avoid inheritance for a class?
Regards,
shankar.
SRI SANKARADOSS.
|
|
|
|
|
There's no such word, but there is a workaround:
- Make the constructor(s) private
- Add a public static method to return a new instance of the class.
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
Hi everybody,
as You may know there are avaible two versions of UDDI registers. Microsoft implemented both and developped kits (UDDI SDK). In my application I use such kit to interact with UDDI register. I must decide at write-time to which one I add reference. But I want to decide about it at run-time because some of registers work with both UDDI versions and some don't.
Any suggestions?
thanks for help
Lukas
|
|
|
|
|