Build an example Maya plugin with .NET – .NET Framework 4.5.1 or 4.5.2


Summary

Maya SDK (DevKit) provide API for .NET.
It requirements can be found in Maya Help ([1], [2]), it’s below:

  • The .NET SDK is installed with Maya as of Extension 2 for Maya 2013.
  • The Maya .NET API uses the .NET 4.5 Framework and is compatible with .NET 4.0 Framework.
  • The Maya .NET SDK is available in 64-bit only. Ensure that your Maya .NET plug-in projects are also compiled in x64.

Microsoft published lifecycle of .NET Framework v4.5.2 It will end on April 26, 2022.

Support for .NET Framework 4.5.2, 4.6, and 4.6.1 will end on April 26, 2022. Customers and developers must have completed the in-place update to .NET Framework 4.6.2 or later by April 26, 2022 to continue receiving technical support and security updates.

https://docs.microsoft.com/en-us/lifecycle/faq/dotnet-framework#what-is-the-microsoft-lifecycle-policy-for–net-framework-

However, Maya’s help has the following description.

The Maya .NET API uses the .NET 4.5 Framework and is compatible with .NET 4.0 Framework.

https://help.autodesk.com/view/MAYAUL/2022/ENU/?guid=Maya_SDK_Maya_NET_API_Getting_started_with_NET_API_html

No description was found to indicate that the Maya API supports .NET Core in Maya help. And, No active exchange of ideas was found in the online community. I have reached this thread the community.

  • .Net Api as .Net Core – Autodesk Community – Maya
  • On the other hand, the .NET ecosystem is powerful. So, let’s try to build an example Maya plugin.

    Prerequisites

    • Maya 2022.2
    • Maya 2022 Update 2 win64 DevKit
    • Windows 10 v21H1
    • Visual Studio 2019

    Steps

    Steps of building an example Maya plugin with .NET is here.

    1. Get devkit from Maya Developer Center.
    2. Open examples.sln.
      • examples.sln is below:
        • C:\Autodesk_Maya_2022_2_Update_DEVKIT_Windows\devkitBase\devkit\dotnet\examples\examples.sln
        • The solution file contain examples.csproj. It specified .NET Framework 4.5.1 in Target framework.
        • .NET Framework 4.5.1 ended on January 12, 2016. Anyway, I will continue to build an example Maya plug-in with the current settings…
    3. Click Add Reference..., then import openmayacs.dll.
      • openmayacs.dll is below:
        • C:\Program Files\Autodesk\Maya2022\bin\openmayacs.dll
    4. Create examples.nll.dll with Build Solution (Ctrl + Shift + B).
      • examples.nll.dll is below:
        • C:\Autodesk_Maya_2022_2_Update_DEVKIT_Windows\devkitBase\devkit\dotnet\examples\assemblies\examples.nll.dll
    5. Copy examples.nll.dll to your MAYA_PLUG_IN_PATH.
      • MAYA_PLUG_IN_PATH include C:\Program Files\Autodesk\Maya2022\bin\plug-ins as value.
    6. Load examples.nll.dllon Maya.
      1. Click Windows > Settings/Preferences > Plug-in Manager.
      2. Search with examples in the Plug-in Manager.
      3. Click Loaded.
    Information of examples.nll.dll in examples.csproj
    Adding openmayacs.dll as reference
    Loading examples.nll.dll

    Result

    Type helloWorldCmdCSharp to Script Editor. The editor display by clicking Windows > General Editors > Script Editor.

    Run command, then the Script Editor will display Hello World.

    helloWorldCmdCSharp worked fine also when i built with .NET Framework 4.5.2.

    References

    1. Maya Help | Maya .NET API | Autodesk
    2. .Net Api as .Net Core – Autodesk Community – Maya
    3. Lifecycle FAQ – .NET Framework | Microsoft Docs