R
Ryan
Hi All,
I quite new to c# development but I'm getting to grips with it quite
well comming from a mainly C++ / Delphi background. I've been following
the msdn artical entitled "An Introduction to P/Invoke and Marshaling on
the Microsoft .NET Compact Framework" and in the section entitled
handling errors there is a vb function called HandleCeError which has
the exception passed to it, by value, which is then processed. I've been
trying to convert this to c# code with no luck as I can't seem to get
the parameter correct to pass the excption accross. My code looks like this:
private void HandleCeError(ref Exception MyException, string Method)
{
if(MyException is NotSupportedException){
// Show Message
}
else if(MyException is MissingMethodException){
// Show Message
}
else{
// Show Message
}
}
Then when I do:
try{
// Platform Invoke Code
}
catch(Exception e){
HandleCeError(ref e, "My Function");
}
and compile it I get:
An object reference is required for the nonstatic field, method, or
property 'HandleCeError(ref System.Exception, string)'
and this is the same with or without the Ref keyword. Can anyone point
me in the right direction as to where I'm going wrong.
Thanks
Ryan
I quite new to c# development but I'm getting to grips with it quite
well comming from a mainly C++ / Delphi background. I've been following
the msdn artical entitled "An Introduction to P/Invoke and Marshaling on
the Microsoft .NET Compact Framework" and in the section entitled
handling errors there is a vb function called HandleCeError which has
the exception passed to it, by value, which is then processed. I've been
trying to convert this to c# code with no luck as I can't seem to get
the parameter correct to pass the excption accross. My code looks like this:
private void HandleCeError(ref Exception MyException, string Method)
{
if(MyException is NotSupportedException){
// Show Message
}
else if(MyException is MissingMethodException){
// Show Message
}
else{
// Show Message
}
}
Then when I do:
try{
// Platform Invoke Code
}
catch(Exception e){
HandleCeError(ref e, "My Function");
}
and compile it I get:
An object reference is required for the nonstatic field, method, or
property 'HandleCeError(ref System.Exception, string)'
and this is the same with or without the Ref keyword. Can anyone point
me in the right direction as to where I'm going wrong.
Thanks
Ryan