The MissingMethodException "is thrown when there is an attempt to
dynamically access a method that does not exist." [1] The compiler
reports an error if code tries to access a nonexistent method on a
class. This exception suggests that you are running afoul when invoking
a method that is dynamically identified.
>My exception just vanishes into thin air and gets replaced by that
exception.
I suspect that you are assessing the situation incorrectly. More likely,
the MissingMethodException is being thrown before any of your code could
generate a custom exception.
You showed us
if(OnPropertyChanged != null)
{
try
{
OnPropertyChanged(...);
}
...
}
How is OnPropertyChanged declared? How is it initialized? In particular,
is every non-null value of OnPropertyChanged absolutely guaranteed to be
a method that can be invoked as shown? Do the signatures (argument and
return types) match identically? Is there any method overloading
involved in this code?
Please show us a complete, minimal example that illustrates the problem.
As a separate issue, you should reexamine your exception handling logic.
>my [custom] exception contains information that I need to present to
the user
If that is the case, then you should catch the type of your exception
like this:
class InvalidPropertyChangeException : Exception { /* ... */ }
try
{
// ...
}
catch ( InvalidPropertyChangeException ex )
{
// access the custom exception
// process exception, rethrow if necessary
}
catch ( Exception ex ) // unexpected exception
{
// process exception, rethrow if necessary
}
Cheers,
Stuart Celarier, Fern Creek
[1]
http://msdn.microsoft.com/library/en...stemmissingmet
hodexceptionclasstopic.asp