I have an external app written in c# that calls a VB .Net script in manifold. When I start a new script from scratch with references to standard .NET modules everything works until at some point I have a bug in my code. This results in a 'Can't launch script'-error 0x80020009. And now it's getting mysterious. Commenting out more and more of the code that runs fine in GUI when the initial error is eliminated I can narrow don't the error persisting in the external application to a very basic part of the code: ' VB .Net Imports M = Manifold.Interop Imports Manifold.Interop.Scripts Class Script Shared Sub Main Dim doc As M.Document, comps As M.ComponentSet doc = Context.Application.ActiveDocument comps = Doc.ComponentSet <- this line produces the error in an external app ' ... End Sub End Class What may be the reason and how to get around? I have seen some threads covering this error but all solutions do not apply here. Whats really special is that it ran until I produced and eliminated an error some 50 lines of code below. Could it be the external application doesn't offer the correct context for some reason? It has'nt been recompiled. Here is how I call the script in c#: // c# M.ComponentSet m_CompSet; int BeforePageExport_index; // Test if script "PlotSet_BeforePageExport" exists BeforePageExport_index = m_CompSet.ItemByName("PlotSet_BeforePageExport"); if (BeforePageExport_index >= 0) { if (m_CompSet[BeforePageExport_index].Type != M.ComponentType.ComponentScript) { BeforePageExport_index = -1; ret = MessageBox.Show(" Component 'PlotSet_BeforePageExport' present\nbut not of expected type 'Script'", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } if (BeforePageExport_index >= 0) m_Script = (M.Script)m_CompSet[BeforePageExport_index]; // ... m_Script.Run(); (Win 10 x64, a script in Mfd 8.0.29 called by my PlotSet_Manager (http://www.schnittstelle-oekologie.de/downloads/?p=73 - compiled for x86 as I have some machines running 32bit Mfd on x64 machines)
Do you really want to ruin economy only to save the planet? |