打印内存高解决方案

只要在ScriptObject里面加上以下代码,然后打印的时候通过调用window.external.PrintView就可以了
 

private static object printObj;

 

public void PrintView(string xml, string encoding, string type, string alwaysReload)

{

    string path = Path.Combine(Application.StartupPath, "HTEMREditorLib.exe");

    string typeName = "HTEMREditorLib.Gui.EMRPrintView";

    if (alwaysReload == "1")

    {

        AppDomain domain = AppDomain.CreateDomain("PrintView");

        object obj = domain.CreateInstanceFromAndUnwrap(path, typeName);

        obj.GetType().GetMethod("PrintView").Invoke(obj, new object[] { xml, encoding, type });

        obj = null;

        AppDomain.Unload(domain);

    }

    else

    {

        if (printObj == null)

        {

            Assembly assembly = Assembly.LoadFrom(path);

            printObj = assembly.CreateInstance(typeName);

        }

        printObj.GetType().GetMethod("PrintView").Invoke(printObj, new object[] { xml, encoding, type });

    }

}

 
原文地址:https://www.cnblogs.com/quietwalk/p/4182289.html