|
I'm trying to construct a delegate manualy, at runtime, from an object refference, and a pointer to a method's runtime handle. However, when i try and compile to code :
<br />
System.Windows.Forms.TreeViewEventHandler thing<br />
= new System.Windows.Forms.TreeViewEventHandler(obj, ip);<br />
It throws an error message saying - "Method Name Expected"
How can I get around this?
regards
Cata
|
|
|
|
|
|
Cheers, got to it about 10 seconds after u posted
|
|
|
|
|
It seemst that VS.net doesn't like me running away on my own with delegates. So i just reflected it.
If anyone is interested - Here is the code (Exception Handling omitted for ease of reading):
<br />
public static object InvokeDelegateViaReflection(Type delegateType, object obj, MethodInfo method)<br />
{<br />
ConstructorInfo ci = delegateType.GetConstructors()[0];<br />
<br />
object[] args = new object[]{@obj, method.MethodHandle.GetFunctionPointer()};<br />
<br />
object result = ci.Invoke(<br />
BindingFlags.Public | BindingFlags.Static | BindingFlags.CreateInstance,<br />
null,args,null); <br />
<br />
return result;<br />
}<br />
Hope that helps someone
Cata
|
|
|
|
|
Cool, I didnt actually suggested that
I was thing along the lines of Delegate.CreateDelegate(Type, Object, String) : Delegate , but you method is perhaps 'stricter'
xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
|
|
|
|
|
source code for voice chating on LAN using C#
|
|
|
|
|
|
Colin Angus Mackay wrote:
And your question is???
As usual...
Give me "source code for voice chating on LAN using C# "
or maybe
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
|
I have requested Source code or any help or logic for
voice communication over LAN.thanks for help.but i m sorry i cannot understand mentioned website or i cannot get source code.please help me an give more information
THANKX
|
|
|
|
|
Anonymous wrote:
i cannot understand mentioned website or i cannot get source code
Nobody mentioned a web site.
No one was able to help. This could be for a number of reasons.
1. No one here has experience of writing voice chatting programs
2. There are experienced people here, but the answer would be long and complex and most people don't have that much time.
3. Your request is too vague.
Questions that generate good answers are generally very specific and do not ask for a whole system.
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Hi
I am using .NET Beta 2 now I have a big problem - all my apps exit after some minute without any comment. If I run them in debug mode, I get this in the output window:
The program '[5704] test.exe: Managed' has exited with code -1073741819 (0xc0000005).
Do you know what the problem could be?
Thanks
/Edit:
I know now that this occours if a remote machine disconnects "unnormally" from the application.
If I, for instance, connect to test.exe with some program and then kill the connecting program... then test.exe will disappear...
|
|
|
|
|
Hi,
actually, it should be Lo...
Try to load a form.
On my pc I get a package load error.
If I try to run it, the beta 2 'stuff' just crashes...
Robert
|
|
|
|
|
Hi,
Heres an example of what i am doing now...
line 01 RECORD 1 ,RECORD 2 ,RECORD 3
line 02 data,data,data
line 03 data, ,data
line 04 data,data,data
line 05 RECORD 4 ,RECORD 5 ,RECORD 6
line 06 data,data,data
line 07 data,data,data
line 08 ,data,
line 09 data, ,data
line 10 RECORD 4 ,RECORD 5 ,RECORD 6
line 11 data,data,data
line 12 data, ,data
line 13 data,data,data
I am iterating through the file line by line, because the data between the blocks of records are inconsistent, i'm using regular expresion to test for the begining of the next record so that i know what data to process. the problem is that the method that is making use of this piece of code is required to return only 1 record at any one time. i have managed to solve the 1 record at a time issue by keeping track of the records that were returned and then following a few other steps.
Because I'm testing for the beginning of the next record, the StreamReader will alwaus pass the point at which I need to be in order to read the next block of records that I need to process. i.e line
I have tried moving the position of the base stream to less than to where/what it currently is by doing the following..
_myFile.BaseStream.Position = _myFile.BaseStream.Position - _previousLineData.Length;
but this doesn't work
In addition, both overloads of the Peek() method of the StreamReader are of no use to me (since they only peek for characters without advancing the StreamReader) and i need to read the whole line to test the RegEx in order to determine whether i have reached the end of a block of records.
as can be seen by the generic sample of the file data above, the data in the file is not well organised and or managed.
any help/hints and advice will be much appreciated..
Thanks a million
Afzal Hassen
|
|
|
|
|
I want to add flash (swf) into my application
for example flash buttons..etc..
How can I do that?
|
|
|
|
|
Does anyone know how to do this? I'm trying to make a source code editing program and I would like intellisence/autocomplete intregrated into it. I have looked at the shell extensions example here and it will only work with the first word you type. The .net 2.0 Express beta only had auto complete for single lines (and only the first letter as well).
I just had an idea to put the currently typed(ing) word into a buffer and use autocomplete on that. Can anyone think of a better way?
|
|
|
|
|
You can have a look at this project[^]), where similar features are available in the source-code editor.
|
|
|
|
|
gah, I feel so dumb I never even thought of that
|
|
|
|
|
Hi all,
I am writing simple windows form application with VS.NET 2003, It loads images selected from Openfiledialog in Listview its fine but How can I get listview to scroll to the selected item.
Regards.
Maulikce
|
|
|
|
|
Easy - ListView1.Items(Index).EnsureVisible(); or myListViewItem.EnsureVisible();
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Please help me,I want to extract the sql query from a report in C# and after I modify the sql, the report change after the new sql.
Thanks.
|
|
|
|
|
i was wondering if it's best to use a global variable or a local one which is each time allocated?
for exemple in a paint event
i would think it's better to create the brush and graphics handle before (eg in constructor)
but in exemple code i've seen them in the paint method so they are allocated each time a paint is occured...
|
|
|
|
|
depends when and how much are u gonna use them.
If the brushes are only used in the paint event , just create them there and when u finish the paint just free them , that way ull gain more resources.
A local variable is only of use to those in the same method as she is.
A global variable will be usable by all the class, if u would use the brushes in 3 or 4 methods just create it global so ull create once.Normally gobal variables are used to control methods or handles like threads and such.
if u create the brushes global ull be using the memory al the time cause ull carry them along the class, if u create them local then ull create them and freeing the memory after u used them.
Usually the few global variables u use the better structured is the class.
|
|
|
|
|
i just thought that because of GC it would be bad to allocate each time
|
|
|
|
|
It would be more efficient to allocate in the constructor. You are anyway going to use it everytime a paint occurs, you might as well cache it. And because Brush and Graphics handles will have unmanaged resources, it would be more efficient to get them once and hold on to them rather than acquiring and releasing them every time.
That said, the .NET GC is very good at cleaning up objects that are destroyed soon after creation, so you might want to measure it up using a profiler.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|