API Guide > Maya .NET API >

# Removal of MStatus return codes from .NET API

The MStatus class does not exist in the Maya .NET API. Functions that return an MStatus in C++ have been converted to void functions or return a boolean in C# to indicate special cases to Maya; for example, if Maya is expected to do processing in place of the plug-in. In the .NET API, these functions return true in place of MStatus.kSuccess and false otherwise.

The following function returns false instead of MStatus.kFailure:

- MPxCacheFormat::isValid()

The following functions return false instead of MStatus.kUnknownParameter:

- MPxNode::compute()
- MPxNode::legalConnection()
- MPxNode::legalDisconnection()
- MPxNode::connectionMade()
- MPxNode::connectionBroken()
- MPxNode::shouldSave()
- MPxFluidEmitterNode::fluidEmitter()
- MPxControlCommand::doEditFlags()
- MPxControlCommand::doQueryFlags()
- MPxManipContainer::doPress()
- MPxManipContainer::doDrag()
- MPxManipContainer::doRelease()
- MPxManipulatorNode::doPress()
- MPxManipulatorNode::doDrag()
- MPxManipulatorNode::doRelease()
- MPxManipulatorNode::doMove()
- MPxModelEditorCommand::doEditFlags()
- MPxModelEditorCommand::doQueryFlags()
- all virtual functions in MPxConstraintCommand except for appendSyntax()

The following functions return false instead of MStatus.kNotImplemented:

- MPxHardwareShader::getAvailableImages()
- MPxHardwareShader::renderImage()
- MPxHardwareShader::renderSwatchImage()
- MPxHwShaderNode::getAvailableImages()
- MPxHwShaderNode::renderImage() 4 args
- MPxHwShaderNode::renderImage() 5 args
- MPxHwShaderNode::renderSwatchImage()

The following function returns false instead of MStatus.kNotFound

- MPxGlBuffer::open()

This behavior also applies to the Maya functions that a plug-in calls. For instance, a function that in C++ returns kFailure in case of a failure instead throws an exception of type ApplicationException in C#. The following are the possible types of exceptions:

- ApplicationException (instead of kFailure or kLicenseFailure)
- InsufficientMemoryException (instead of kInsufficientMemory)
- ArgumentException (instead of kInvalidParameter)
- ArgumentNullException (instead of kInvalidParameter when the parameter is null)
- ArgumentOutOfRangeException (instead of kInvalidParameter when the parameter is not in the expected range)

When Maya calls a function of your plug-in (for example, the virtual method doIt() of a MPxCommand derived class), it always wraps the call with a try-catch clause. When it catches an exception thrown either by your function or by a Maya function that your function calls, a message box appears and displays the details of the exception, including the callstack, which may be very useful for debugging.

Important

Thanks to this high-level try-catch, you do not have to wrap any call to a Maya function with a try-catch clause unless you want to react to an exception in a particular way.