I have a login component in my project. I have done it using WPF and C#.NET 3.0, Sql server 2005 express. I have stored the passwords as plain text which is a security risk. Now I have to add security feature to my database. Is there any APIs / functions available in .NET to encrypt the password and save it in the database. Hope to see an answer soon...
thanks
|
Hi All,
I have written the below code to get the Name and Type of the properties in a class. Here I am getting the Name of the Type if it is not nullable if the type is nullable I am getting as "Nullable'1" How to get the Type irrespective of the Nullable.
Code Snippet
foreach (PropertyInfo Info in typeof(MyClass).GetProperties())
{
HeaderText += Info.Name + ",";
DataType += Info.PropertyType.Name + ",";
}
The output of DataType is like this.
Int32,DateTime,Nullable`1,String,String,Int32,Int32
Here the third value is declared as
Code Snippet
private System.NullableDateTime> _EndDateTime;
How to get the Type of the Nullable?
Thanks
Anandraj.A.
|
Microsoft has created a new forums platform (MSDN, TechNet, Expression, and Microsoft) with increased performance, stability, and an improved user experience. The forum you previously accessed has been moved to this new platform. To help you with this move, weÆve created a Sandbox forum, where you can create threads and try out functionality, and a suggestions forum where you can give us your feedback. Please take some time to go to these new forums today and let us know what you think: Thank you for your continued support!
|
I have an application that runs with no issues except that if the pc has a larger font setting for its system settings my application takes the larger font size and adjusts the fonts within my app. Is there any way to ignore the current system font settings and display font size to what I have defined in code ?
|
How can I declare in C# an array of simple structs (containing only integers) and then pass that by ref to C? also passing the number of elements.
I want managed code to be able to declare any one-dimensional array it likes, 5 elements or 25 elements or 100, and then pass a ref to that array and the element count.
The called C code will then populate the array elements but never more than 'cont'.
When I do this, it works in the sense that the called code can see each element (with test values put in) but when the function returns to C#, the original managed array is always redefined somehow to being one element long !!!
Here are details:
Code Snippet [StructLayout(LayoutKind.Sequential)] public struct HandleInfo { public UInt64 handle; public UInt32 owner_pid; public UInt32 owner_tid; }
[DllImport("APIDLL", SetLastError = true)] public static extern bool LibGetHandleInfo(uint rep, ref HandleInfo[] info, UInt32 num); Export BOOL LibGetHandleInfo (VMXHDL p, Lib_handle_info * hinfos[], DWORD num_entries)
The caller does this:
HandleInfo[] infos = new HandleInfo[10];
Library.LibGetHandleInfo(id, ref infos, 10); As I say, upon return the array is NO LONGER ten elements, but ONE (debugger throws bounds exception if I try to look at element [1] for example).
This is VERY confusing!!
Thx Hugh
|
I have been trying to figure this out all day and have no other recourse than to seek direct help, thanks to any that chime in.
I will explain the problem simply first to see if there is a "duh this is how you do it" solution. I have a custom control I have created that I have placed on a form. In one of my custom control events I would like to call a function from the form class it was placed on. For the life of me I cannot figure out how to get a hook into the form the custom control is placed on.
I tried to create a new form in the event and assign it with findform() but that does not open up the functions I have created in my class form.
Is there a way I can have my main form subscribe to the event in my control so I can do something in main form everytime the event occurs in the custom control?
Any help is appreciated, I will check this post in the morning and answer any questions any people might have if that means they can better assist.
Thanks,
Zeke
|
Hello Forum,
Thank you in advance for any help. I am trying to create a compare statement to take a line of text I have created and have it run a procedure until it matches a string statement I have determined. I am having problems reading the line and then transferring it into a string I can compare against.
Can Anyone help?
namespace ReadString
{
class Program
{
// SO WE CONNECT HERE *********************************************
static void Main(string[] args)
{
Connect to whatever file on my desktop
// WE CREATE THE STRING HERE ****************************************
// WE ALSO READ INPUT AND DISPLAY INFORMATION ***********************
string x = "Hello World";
Console.WriteLine(x);
byte[] WriteBuffer = new byte[1024];
ASCIIEncoding en = new System.Text.ASCIIEncoding();
WriteBuffer = en.GetBytes(x);
netStrm.Write(WriteBuffer, 0, WriteBuffer.Length);
Console.WriteLine(strRead.ReadLine());
// HOW DO I DO THIS STATEMENT WHICH JUST WANTS TO COMPARE IF THE //INFORMATION IN strRead.ReadLine == “Hello World”?????
if ( String.Compare( THE INFORMATION IN strRead.Readline, "Hello World"))
{
statements;
}
else
morestatements;
|
We are currently migrating this forum. Therefore we have disabled posting new threads and messages. Please be patient with us during this process. When migration is complete, this url will redirect to its new location.
|
Hi all,
Sometimes I say Net, instead of Dot Net, like "the Net Framework". Is this wrong? Can it be used this way?
Thanks, Aw
|
Hi all,
Anyone knows if they differ in performance, memory requirements, etc?
The reason I ask is, I want to have a private static field that should be used by all the instances of the class commonly. Would this have any disadvantage vs having it locally for each instance?
Thanks, Aw
|
I've done something very similar to this is VB several years back. In a nutshell, I have a modem connected to my serial port (its actually a USB to serial adapter, but is treated just like a real UART, so the interface is the same). I'm polling the modem to get information about the chipset. What I've done is create a function that sends the command string and returns the results. I call this function several times to gather all the information and put it in the fields. Now, the modem can only handle one command/response at a time. When I execute the code, it appears that the functions are trampling each other.
The code follows. What happens is I send the command ATI6 to the serial port and then I need to wait for the modem to respond. What I think is happening is that the ATI0 is being sent before the modem has responded to the ATI6 command. Any ideas?
Thanks,
BC
private void buttonStart_Click(object sender, EventArgs e)
{
String stringdata;
...
...
...
// Display the model number
textBoxChipset.Text = GetInfo("ATI6");
// Dump any other data to the temp box
textBoxData.Text += serialPort1.ReadExisting();
// Display the Revision
textBoxChiprev.Text = GetInfo("ATI0");
...
...
}
private string GetInfo(string varstring)
{
string stringdata;
stringdata = "";
try
{
serialPort1.WriteLine(varstring);
}
catch (TimeoutException)
{
MessageBox.Show("Timeout sending " + varstring);
}
System.Threading.Thread.Sleep(200); // sleep thread (ms)
try
{
stringdata = serialPort1.ReadLine();
}
catch (TimeoutException)
{
MessageBox.Show("Timeout receiving " + varstring);
}
textBoxData.Text += stringdata;
try
{
stringdata = serialPort1.ReadLine();
}
catch (TimeoutException)
{
MessageBox.Show("Timeout receiving " + varstring);
}
textBoxData.Text += stringdata;
try
{
stringdata = serialPort1.ReadLine();
}
catch (TimeoutException)
{
MessageBox.Show("Timeout receiving " + varstring);
}
textBoxChipset.Text = stringdata;
return stringdata;
}
|
Hi everyone !
I want to store information which is in form of tree structure. like Root node then its child and further like this.
which is the best data structure to use ?
Does c# provide Tree class ?
any help will be greatly appriciated.
|
Hello, I'm trying to make a simple pc-pc communication using RTC. I want to include messaging, audio and video communication. Atm im stucked with messaging. I start my application on pc1 listening for incomming connections.
SetMediaTypes();
_rtc.EventFilter = 0x01FFFFFF; _rtc.ListenForIncomingSessions = RTC_LISTEN_MODE.RTCLM_BOTH; //Creation of the manager of event _rtc.IRTCEventNotification_Event_Event += new IRTCEventNotification_EventEventHandler(RTC_IRTCEventNotification_Event_Event); this.richTextBox1.AppendText("\nListening..");
On pc2 i initiate a connection with pc1;
SetMediaTypes();
_session = _rtc.CreateSession(RTC_SESSION_TYPE.RTCST_PC_TO_PC, null, null, 0); //Add the participant in the session. nume = this.textBox1.Text; adresaIP = this.textBox2.Text; _session.AddParticipant(adresaIP, nume); this.richTextBox1.AppendText("\nConnecting to " + adresaIP + "..");
pc1 answers the connection (or so i think). private void OnIRTCSessionStateChangeEvent(IRTCSessionStateChangeEvent sessionEvent) { RTC_SESSION_STATE sessionState;. sessionState = sessionEvent.State; switch (sessionState) { case RTC_SESSION_STATE.RTCSS_INCOMING: { _rtc.PlayRing(RTC_RING_TYPE.RTCRT_PHONE, true); this.richTextBox1.AppendText("\nIncoming..."); this.richTextBox1.Focus(); this.richTextBox1.ScrollToCaret(); _session.Answer();
//ding!
} break; case RTC_SESSION_STATE.RTCSS_CONNECTED: { this.richTextBox1.AppendText("Connected"); } break; } }
After _session.Answer() the code exits OnIRTCSessionStateChangeEvent, //ding! would never make out. Now i try to send messages from pc1 to pc2 and viceversa. private void button3_Click(object sender, EventArgs e) { string msgHeader, msg; msgHeader = "plainMessage"; msg = this.textBox3.Text; _session.SendMessage(msgHeader, msg, 0); this.richTextBox1.AppendText("\nI say: " + msg); this.richTextBox1.Focus(); this.richTextBox1.ScrollToCaret(); } I get Exception from HRESULT: 0x80EE0029 for _session.SendMessage(msgHeader, msg, 0); The error value means The client is already initialized. sooo? I thought i need another session to creat for messaging so, if i use a different code for sending message private void button3_Click(object sender, EventArgs e) { string msgHeader, msg; msgHeader = "plainMessage"; msg = this.textBox3.Text; nume = this.textBox1.Text; adresaIP = this.textBox2.Text; _msgSession = _rtc.CreateSession(RTC_SESSION_TYPE.RTCST_IM, null, null, 0); _msgSession.AddParticipant(adresaIP, nume); _msgSession.SendMessage(msgHeader, msg, 0); this.richTextBox1.AppendText("\nI say: " + msg); this.richTextBox1.Focus(); this.richTextBox1.ScrollToCaret(); }
my messages are sent but only 1way, from the pc who initiated the connection (pc2), pc1 doesn't send anything or at least pc2 doesn't get them. Also, a new connection is initiated, this is normal according to _msgSession.AddParticipant(adresaIP, nume); so this is not an option. I think i shouldn't create a new session for each type of communication, i should go back to _session.SendMessage code where i get the error. Any ideas how to fix it? Thanks
|
Hi all,
I have a Matrix class that holds 3 vectors. I want to be able to transfer these vectors to somewhere else if the Matrix itself is destroyed by the GC.
Is this possible? Is there a way to know before an object is destroyed? Using a destructor would do? Or destructors are called after the object is destroyed?
So it will be like this:
myMatrix = Matrix3x3 (v1,v2,v3)
Preserved(v1,v2,v3)
myMatrix is no more...
Thanks, Aw
|
Hi All,
I am trying to call an unmanaged C++ DLL from C#. I am getting an error "Unable to find an entry point named 'Add' in DLL 'MathFuncsDll.dll"
This may be or may not be an issue but the unmanaged DLL is in system32 folder and managed dll is GAC'ed. Code excerpts below and thanks for your pointers!
C++ header file:
Code Snippet
#ifdef MATHFUNCSDLL_EXPORTS
#define MATHFUNCSDLL_API __declspec(dllexport)
#else
#define MATHFUNCSDLL_API __declspec(dllimport)
#endif
// This class is exported from the MathFuncsDll.dll
class MATHFUNCSDLL_API CMathFuncsDll {
public :
CMathFuncsDll( void);
// TODO: add your methods here.
};
extern MATHFUNCSDLL_API int nMathFuncsDll;
MATHFUNCSDLL_API int fnMathFuncsDll(void);
namespace MathFuncs
{
class MyMathFuncs
{
public:
// Returns a + b
static __declspec(dllexport) double Add(double a, double b);
};
}
C++ header file:
Code Snippet
#include "stdafx.h"
extern "C" {
#include "MathFuncsDll.h"
}
#include
using namespace std;
// This is an example of an exported variable
MATHFUNCSDLL_API int nMathFuncsDll=0;
// This is an example of an exported function.
MATHFUNCSDLL_API int fnMathFuncsDll(void)
{
return 42;
}
// This is the constructor of a class that has been exported.
// see MathFuncsDll.h for the class definition
CMathFuncsDll::CMathFuncsDll()
{
return;
}
namespace MathFuncs
{
double MyMathFuncs::Add(double a, double b)
{
return a + b;
}
}
C# Source:
Code Snippet
[ DllImport("MathFuncsDll.dll", EntryPoint = "Add")]
public static extern double Add(double a, double b);
//Call the CPP method
double testDouble = Add(2.0, 3.0);
testCol = testDouble.ToString();
I get an error which says that "Unable to find an entry point named 'Add' in DLL 'MathFuncsDll.dll'."
|