[ADVANCED-DOTNET] Global hook in .NET

2008-04-11 Thread Arun
Can i set a global hook on the wind proc in .NET. I am willing to write the hook procedure in unmanaged dll. I want to capture the window messages of another application (.NET) from my host application (again .NET). Thanks in advance Regards Arun === This list is

Re: [ADVANCED-DOTNET] Storing shared secrets

2008-04-11 Thread Arun
Can i set a global hook on the wind proc in .NET. I am willing to write the hook procedure in unmanaged dll. I want to capture the window messages of another application (.NET) from my host application (again .NET). Thanks in advance Regards Arun === This list is

Re: [ADVANCED-DOTNET] Strange behavior with method overload resolution

2008-04-11 Thread Mark Hurd
And what you suggest actually works in well with my suggestion: Dim X as Object = Nothing TryParse("", X) TryParse(Of Object)("", X) _ function TryParse(byval Input As String, byref Value As Object) As Boolean WL("Object direct") return True end function function TryParse(Of T)(byval Input

Re: [ADVANCED-DOTNET] Strange behavior with method overload resolution

2008-04-11 Thread Sébastien Lorion
Hum, I don't know how generalized that scenario is, but it sure does not look clean to me and if I really want to do that, I would use the more explicit call TryParse(input, out value) to make clear my intention. Anyway, I can live with that, I will just be more careful to watch for yet another t

Re: [ADVANCED-DOTNET] Strange behavior with method overload resolution

2008-04-11 Thread Mark Hurd
On 12/04/2008, Sébastien Lorion <[EMAIL PROTECTED]> wrote: > Well, in my code I have another method similar to: > > void DoStuff(Type type, string input) > { > object value; > if (TryParse(input, out value)) > { >// ... > } > } > > I made a mistake and forgot to pass "type" to TryParse. I d

Re: [ADVANCED-DOTNET] Strange behavior with method overload resolution

2008-04-11 Thread Sébastien Lorion
make that: static void DoStuff(Type type, string input) { object value; if (TryParse(input, out value)) { // ... } } On 4/11/08, Sébastien Lorion <[EMAIL PROTECTED]> wrote: > Well, in my code I have another method similar to: > > void DoStuff(Type type, string input) > { > object value

Re: [ADVANCED-DOTNET] Strange behavior with method overload resolution

2008-04-11 Thread Sébastien Lorion
Well, in my code I have another method similar to: void DoStuff(Type type, string input) { object value; if (TryParse(input, out value) { // ... } } I made a mistake and forgot to pass "type" to TryParse. I discovered the bug only at runtime when testing my code. I can understand the

Re: [ADVANCED-DOTNET] Strange behavior with method overload resolution

2008-04-11 Thread Barry Kelly
Sébastien Lorion <[EMAIL PROTECTED]> wrote: > The following program outputs: > > in Parse, type='System.Int32' This is a run time type object you passed in explicitly. > in Parse, T='System.Object' Here, T was inferred at compile time, not run time. > Is this behavior intended and if yes, why

Re: [ADVANCED-DOTNET] Strange behavior with method overload resolution

2008-04-11 Thread Greg Young
object value; Parser.TryParse(typeof(int), "1", out value); is a valid call to the second (non-generic method). It would seem to me that it is then inferring T as object here ... return TryParse(input, out value); because if public static bool TryParse(string input, out T value)

[ADVANCED-DOTNET] Strange behavior with method overload resolution

2008-04-11 Thread Sébastien Lorion
The following program outputs: in Parse, type='System.Int32' in Parse, T='System.Object' Is this behavior intended and if yes, why ? I would expect a compile error. using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { object value;