[.net Max SDK] ActiveViewExp crash

Hey, I’m trying to get a GraphicsWindow using the .net max SDK. The problem is that when I try to get the active viewport it crashes:

'Method not found: ‘Autodesk.Max.IViewExp Autodesk.Max.IInterface.get_ActiveViewExp()’

This is the code:

IGlobal global = Autodesk.Max.GlobalInterface.Instance;
IViewExp activeViewport = global.COREInterface.ActiveViewExp;
IGraphicsWindow gWindow = activeViewport.Gw;

So it crashes at global.COREInterface.ActiveViewExp but I don’t understand why… ‘Method not found’, does that mean it doesn’t exist in the .net SDK?

I’m not sure if this matters but my code isn’t a plugin yet, just a custom user control loaded in max. Like this:

dotnet.loadAssembly "C:\\...path...\\TestApp.dll"
local m_TestClass = dotNetObject "TestApp.UserControl1"

Thanks in advance,

IGlobal global = Autodesk.Max.GlobalInterface.Instance;
IInterface ip = global.COREInterface;
IViewExp activeViewport = ip.ActiveViewExp;
IGraphicsWindow gWindow = activeViewport.Gw;

I think I had some issues like that before, but when I cast the IInterface to it’s own variable and call the method from there it works. Not sure how it can be related but it’s worth a try.

If this doesn’t solve it, you might have some other problem in that function, feel free to share it.