|
Hi!
I am developing a mulititier application.
I created some value classes with custom attributes specification.And i have seperate query builder class.This query builder class will construct the query based on the valueobject.Internally the query builder using reflection
reads all propertie's name and custome attributes.Upto that there is no problem.If i try to fetch the value of a property then the runtime error will occurs.For fetching the value i am using PropertyInfo.GetValue method.
So please any on help me to resolve this problem..
Type type=Obj.GetType();
foreach(PropertyInfo f in type.GetProperties())
{
foreach(Attribute attr in Attribute.GetCustomAttributes(f))
{
if(attr.GetType()==typeof(DefaultValueAttribute))
{
str+=":"+f.Name+":"+((ColumnMappingAttribute)attr).Name;
str+=f.GetValue(null,null); --This line shows error
}
}
}
Please help me to solove the problem
M.Sendilkumar
Senior Software Engineer
TVS Infotech
Chennai,TamilNadu,India.
98413 27002
|
|
|
|
|
If you would have read teh documentation for PropertyInfo.GetValue
you would have seen that the first parameter to it is the
"The object whose property value will be returned.".
If you read the Remarks section there, it says
"Because static properties belong to the type, not individual objects, get static properties by passing a null reference (Nothing) as the object argument."
But since you're trying to retrieve a non-static property that line should look like this:
str+=f.GetValue(obj,null);
So next time instead of "Waiting for 2 days" try "Reading the documentation for 5 minutes"
|
|
|
|
|
HI Roman Rodov
Thanks for direct me to have a correct solutions.I tried it, it is working fine.
M.Sendilkumar
Senior Software Engineer
TVS Infotech
Chennai,TamilNadu,India.
98413 27002
|
|
|
|
|
Hi
I creat new thread and run it:
System.Threading.ThreadStart st = new ThreadStart(MyRunig);<br />
tr = new Thread(st);<br />
tr.Name = "MyThread";<br />
tr.Start();<br />
at MyRunig :<br />
System.Windows.Forms.Application.Run();
so I have the new thread with window Q.
How can I send message from the main Thread (GUI) to the new one?
I am looking for Event driven mechanism
I used:
public void SendMyMessage()<br />
{ <br />
PostThreadMessage(fr.Handle,1122,(System.IntPtr)0,(System.IntPtr)0);<br />
} this is the way to send message?
<br />
[DllImport("User32.dll")]<br />
public static extern bool PostThreadMessage( System.IntPtr idThread, int msgID,System.IntPtr pm,System.IntPtr lm);
But I didn't get the message ( with WndProc )
Thanks
Koby
|
|
|
|
|
If you want to call functions on controls belonging to the other thread then you have to define a delegate for each of these functions (for each different method signature at least) and then use Invoke() or BeginInvoke() with these delegates.
Take a look at Control's members for a description of these tunctions.
mav
|
|
|
|
|
Anyone know of an easy way to input dates in the CF platform?
I have a form with a few text edit fields.
The users will probably fudge it up and try wrong formats, etc.
All I can see for now, is breaking up the text, and using "new DateTime(y, m, d)"
Thanks.
"For all of our languages, we cannot communicate" - Christy Moore, Natives
|
|
|
|
|
I've found the answer:
DateTime.Parse
DateTime.ParseExact
"For all of our languages, we cannot communicate" - Christy Moore, Natives
|
|
|
|
|
I have a button on my form. i want to raising the button`s click event.
|
|
|
|
|
Since no-one else seems to answer, I'll jump in:
Very easily by calling myButton.PerformClick();
But beware PerformClick(): It only works when the button is selectable.
When you for example derive a control from button and set its control style to Selectable==false, then PerformClick on this control will have no effect.
Regards,
mav
|
|
|
|
|
thank you.
I have an another question.
how I can rais an desired event(not only Click)?
|
|
|
|
|
There's no consistent way for doing this.
If you want to raise the event from a derived control, then usually the base class offers protected OnEvent... methods to call, but if you're trying to raise an event from a different class than you're probably out of luck.
You usually have to call a method/set a property of the object you want to fire the event in such a way that the event desired is fired.
For example, if you want the TextChanged event of a TextBox to fire you can call
myTextBox.Text = "Some new Text"; and the event gets fired.
If you already have an event handler in your class for the desired event, then you can simply call this method by yourself.
For example:
button1.Click += new EventHandler(this.button1_Click);
...
this.button1_Click(this, new EventArgs());
Regards,
mav
|
|
|
|
|
Does anyone know when the new release for SQL Server and the MSDN will be launched? I am thinking of buying an MSDN subscription, but I don't want to buy if I know if there is a new version coming soon.
Brendan
|
|
|
|
|
If you buy an MSDN Subscription you get all the new software available to you as soon as it comes out. That's why it is called a "Subscription".
|
|
|
|
|
Is there any way to add some controls on a frame windows in SDI/MDI applications (NOT toolbars) ?
|
|
|
|
|
Is there anyone that would have an example of how to change the wallpaper using the systemparametersinfo. How do you use it, what needs to be impoted and an example code would be nice.Thanks.
|
|
|
|
|
How can I display more than 10 projects in the Start Page? (in studio)
"For all of our languages, we cannot communicate" - Christy Moore, Natives
|
|
|
|
|
Change the number of Most Recently Used projects in the options dialog. The affects the list of projects in the file menu also.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
Thanks.
"For all of our languages, we cannot communicate" - Christy Moore, Natives
|
|
|
|
|
Hello @all,
in my Mobile Application (Windows Mobile2003 / CompactFramework / VB.NET) i programmaticly set the focus to a button.
But the Button dont't get the focus??
If i debug the code it works fine (if I can belive the debugger), but the button don't get the focus.
I really don't know what to do. Is anyone here who got the same problem??
Any help is welcome
Regards
Sascha
|
|
|
|
|
How would I go about using the .NET Framework to get and set the Master and Wave Volume of the user's computer? Can it be done with .NET, or is Direct Sound required to do this? Any leads in the right direction would be appreciated.
Happy Programming and may God Bless!
"Your coding practices might be buggy, but your code is always right."
Internet::WWW::CodeProject::bneacetp
|
|
|
|
|
You can P/Invoke waveOutSetVolume() to set the volume of a waveform audio output device.
[DllImport("winmm.dll")]
public static extern int waveOutSetVolume(IntPtr hwo, UInt32 dwVolume);
...
waveOutSetVolume(IntPtr.Zero, 0xFFFFFFFF);
... This sets both channels of master volume to maximum.
For special target devices you might have to use other WaveOut-functions, but they're all documented in the platform SDK.
Regards,
mav
|
|
|
|
|
Thanks for your reply.
Happy Programming and may God Bless!
"Your coding practices might be buggy, but your code is always right."
Internet::WWW::CodeProject::bneacetp
|
|
|
|
|
hi friends,
heard that MTS is not supported in .NET Framework. I guess .NET framework supports COM+ runtime services so how come MTS is not supported ??
tHanKs,
Hatim Ali.
|
|
|
|
|
Hi ali
I guess your are using incorrect version of MTS.If you are using 2000 Professional surely i will not support for COM+.For deploying COM+ components use 2003 server or Latest version of MTS(Non NT flavour)
Thanks
M.Sendilkumar
Senior Software Engineer
TVS Infotech
Chennai,TamilNadu,India.
98413 27002
|
|
|
|
|
M.Sendilkumarm wrote:
I guess your are using incorrect version of MTS.If you are using 2000 Professional surely i will not support for COM+.
Are you sure? Windows 2000 Professional does have support for COM+, and .NET components can be published in the COM+ catalog using the System.EnterpriseServices namespace.
COM+ is "COM + MTS". MTS was introduced in NT 4.0, and became part of the COM+ services in Windows 2000.
Regards,
Serge (Logic Software, Easy Projects .NET site)
|
|
|
|