What is different between DCOM Identity “The interactive user” and “This user” if the username is the same (Administrator)?

StackOverflow https://stackoverflow.com/questions/19056707

سؤال

I’m working on an ASP webpage that uses a Minitab DCOM object. My problem is that this DCOM object stops responding (hangs) if the Identity is set as “This User” under Component Services (DCONCNFG) but if I log into windows with the user that I used under “This User” and set the Identity as “Interactive user” everything works fine.

My question is what is different between DCOM Identity “The interactive user” and “This user” if the username is the same (Administrator)?

Mainly this webpage uses Minitab to generate graphs. Before it hangs it does generate graphs but only 5 or 6 graphs then it stops responding.

Here is the C# code incase you are wondering where it hangs:

using System;
using System.Web;
using System.Web.UI.WebControls;
using Mtb;        // Minitab Library (Mtb 16.0 Type Library)
using System.IO;
using System.Data;
using System.Runtime.InteropServices;
using System.Threading;




namespace TRWebApp.TestDetails
{
    public partial class TestDetails : System.Web.UI.Page
    {

        // MiniTab Stuff
        Mtb.IApplication g_MtbApp;
        Mtb.IProject g_MtbProj;
        Mtb.IUserInterface g_MtbUI;
        Mtb.IWorksheets g_MtbWkShts;
        Mtb.ICommands g_MtbCommands;

        Mtb.IOutputs g_MtbOutputs;
        Mtb.IGraph g_MtbGraph;

        Mtb.IOutputs g_MtbOutputs2;
        Mtb.IGraph g_MtbGraph2;

        int g_GraphIdx = 1;

        int g_Loop = 1;

        // Tests Table
        enum testsTable { TestIdx, TestSeq, ParamName, LSL, USL, Units };

        Tools tools = new Tools();

        string g_SessionID = "";

        Mtb_DataSetTableAdapters.XBarTableAdapter xbarTA = new Mtb_DataSetTableAdapters.XBarTableAdapter();

        protected void Page_Init(object sender, EventArgs e) 
        {
            g_MtbApp = new Application();
            g_MtbProj = g_MtbApp.ActiveProject;
            g_MtbUI = g_MtbApp.UserInterface;
            g_MtbWkShts = g_MtbProj.Worksheets;
            g_MtbCommands = g_MtbProj.Commands;

            g_MtbUI.DisplayAlerts = false;
            g_MtbUI.Interactive = false;
            g_MtbUI.UserControl = false; 


            lblProductDesc.Text = "";       // Start with a clear variable

            g_SessionID = HttpContext.Current.Session.SessionID;


            string imgFolder = "Images/Mtb/";

            string mtbSessionPath = Server.MapPath(ResolveUrl("~/" + imgFolder)) + g_SessionID;

            Directory.CreateDirectory(mtbSessionPath);
            Array.ForEach(Directory.GetFiles(mtbSessionPath), File.Delete); // Delete all the files from the directory

            Session["MtbSessionPath"] = mtbSessionPath;   // Store the Session Path so we can later delete it


            // Add the two image columns to the grid view
            GridView1.AutoGenerateColumns = false;

            ImageField imgColumn = new ImageField();
            imgColumn.HeaderText = "Scatterplot";
            imgColumn.DataImageUrlField = "TestIdx";
            imgColumn.DataImageUrlFormatString = "~\\Images\\Mtb\\" + g_SessionID + "\\{0}.GIF";
            imgColumn.ControlStyle.CssClass = "MtbImgDetail";
            GridView1.Columns.Add(imgColumn);

            ImageField img2Column = new ImageField();
            img2Column.HeaderText = "Histogram";
            img2Column.DataImageUrlField = "TestIdx";
            img2Column.DataImageUrlFormatString = "~\\Images\\Mtb\\" + g_SessionID + "\\H{0}.GIF";
            img2Column.ControlStyle.CssClass = "MtbImgDetail";
            GridView1.Columns.Add(img2Column);


        }

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                lblErrMsg.Text = "";

                // Fill dates if they are empty
                if (String.IsNullOrEmpty(tbxFromDate.Text))
                    tbxFromDate.Text = String.Format("{0:MM/01/yy}", DateTime.Today, null, DateTime.Today);
                if (String.IsNullOrEmpty(tbxToDate.Text))
                    tbxToDate.Text = String.Format("{0:MM/dd/yy}", DateTime.Today);

            }
            catch (Exception ex)
            {
                lblErrMsg.Text = ex.Message;
            }           

        }

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowIndex >= 0)
            {
                // Get the data for the parameter name
                DataTable dt = xbarTA.GetXBarData(lbxProduct.SelectedValue, Convert.ToDateTime(tbxFromDate.Text), Convert.ToDateTime(tbxToDate.Text), e.Row.Cells[(int)testsTable.ParamName].Text);

                // Pass the data to an object array so we can pass it to minitab
                object[] data = new object[dt.Rows.Count];
                object[] time = new object[dt.Rows.Count];

                int i = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    if (tools.IsNumeric(dr["ParamValue"]))
                    {
                        data[i] = Convert.ToDouble(dr["ParamValue"]);
                        time[i] = i;
                    }
                    i++;
                }

                if (dt.Rows.Count > 1)  // Do graphs with at least two measurements
                {
                    // Only pass it to minitab if we have numeric data
                    if (!ReferenceEquals(data[0], null))        // if it is not null it means it has a numeric value
                    {
                        g_MtbWkShts.Item(1).Columns.Add().SetData(data);
                        g_MtbWkShts.Item(1).Columns.Add().SetData(time);

                        g_MtbWkShts.Item(1).Columns.Item(1).Name = e.Row.Cells[(int)testsTable.ParamName].Text + " (" + e.Row.Cells[(int)testsTable.Units].Text + ")";
                        g_MtbWkShts.Item(1).Columns.Item(2).Name = "Time";


                        ////  H  E  R  E
                        ////
                        //// FOLLOWING LINE HANGS AFTER GENERATING 6 GRAPHS WHEN THE IDENTITY "THIS USER" IS SET
                        ////
                        g_MtbProj.ExecuteCommand("Plot C1*C2;\nSymbol;\nConnect.", g_MtbWkShts.Item(1));

                        // Convert LSL and USL to Decimal
                        if (tools.IsNumeric(e.Row.Cells[(int)testsTable.LSL].Text.Trim()) && tools.IsNumeric(e.Row.Cells[(int)testsTable.USL].Text.Trim()))
                        {
                            if (Convert.ToDouble(e.Row.Cells[(int)testsTable.LSL].Text) < Convert.ToDouble(e.Row.Cells[(int)testsTable.USL].Text))
                            {
                                g_MtbProj.ExecuteCommand("Capa C1 " + dt.Rows.Count.ToString() + ";\nLspec " + e.Row.Cells[(int)testsTable.LSL].Text + ";\nUspec " + e.Row.Cells[(int)testsTable.USL].Text + ";\nPooled;\nAMR;\nUnBiased;\nOBiased;\nToler 6;\nWithin;\nOverall;\nCStat.", g_MtbWkShts.Item(1));
                            }
                            else
                            {
                                g_MtbProj.ExecuteCommand("Histogram C1;\nBar;\nDistribution;\nNormal.", g_MtbWkShts.Item(1));
                            }
                        }
                        else
                        {
                            g_MtbProj.ExecuteCommand("Histogram C1;\nBar;\nDistribution;\nNormal.", g_MtbWkShts.Item(1));
                        }

                        try
                        {
                            g_MtbOutputs = g_MtbCommands.Item(g_GraphIdx).Outputs;
                            g_GraphIdx++;
                            g_MtbOutputs2 = g_MtbCommands.Item(g_GraphIdx).Outputs;
                            g_GraphIdx++;

                            string graphPath = "";
                            if (g_MtbOutputs.Count > 0)
                            {
                                g_MtbGraph = g_MtbOutputs.Item(1).Graph;

                                graphPath = Server.MapPath(ResolveUrl("~/Images/Mtb/")) + g_SessionID + Path.DirectorySeparatorChar + e.Row.Cells[(int)testsTable.TestIdx].Text + ".gif";
                                g_MtbGraph.SaveAs(graphPath, true, MtbGraphFileTypes.GFGIF, 600, 400, 96);
                            }

                            if (g_MtbOutputs2.Count > 0)
                            {
                                g_MtbGraph2 = g_MtbOutputs2.Item(1).Graph;

                                graphPath = Server.MapPath(ResolveUrl("~/Images/Mtb/")) + g_SessionID + Path.DirectorySeparatorChar + "H" + e.Row.Cells[(int)testsTable.TestIdx].Text + ".gif";
                                g_MtbGraph2.SaveAs(graphPath, true, MtbGraphFileTypes.GFGIF, 600, 400, 96);
                            }                                
                        }
                        catch (Exception ex)
                        {
                            lblErrMsg.Text = "Test Idx: " + e.Row.Cells[(int)testsTable.TestIdx].Text + " seems to have problems.<BR />Error: " + ex.Message;
                        }

                        g_MtbWkShts.Item(1).Columns.Delete();  // Delete all the columns (This line of code is needed otherwise the Mtb.exe will still running on the server side task manager


                    }
                    else
                    {
                        // Copy the No numeric image as a graph
                        File.Copy(Server.MapPath("~\\Images\\Mtb\\NaN.gif"), Server.MapPath("~\\Images\\Mtb\\" + g_SessionID + "\\" + e.Row.Cells[(int)testsTable.TestIdx].Text + ".gif"));
                        File.Copy(Server.MapPath("~\\Images\\Mtb\\NaN.gif"), Server.MapPath("~\\Images\\Mtb\\" + g_SessionID + "\\H" + e.Row.Cells[(int)testsTable.TestIdx].Text + ".gif"));
                    }
                }
            }
        }

        protected void GridView1_Unload(object sender, EventArgs e)
        {
            // All these lines of code are needed otherwise the Mtb.exe will not be close on the task manager (server side)
            GC.Collect();
            GC.WaitForPendingFinalizers();

            if (g_MtbGraph != null)
                Marshal.ReleaseComObject(g_MtbGraph); g_MtbGraph = null;
            if (g_MtbOutputs != null)
                Marshal.ReleaseComObject(g_MtbOutputs); g_MtbOutputs = null;

            if (g_MtbGraph2 != null)
                Marshal.ReleaseComObject(g_MtbGraph2); g_MtbGraph2 = null;
            if (g_MtbOutputs2 != null)
                Marshal.ReleaseComObject(g_MtbOutputs2); g_MtbOutputs2 = null;

            if (g_MtbCommands != null)
                Marshal.ReleaseComObject(g_MtbCommands); g_MtbCommands = null;
            if (g_MtbWkShts != null)
                Marshal.ReleaseComObject(g_MtbWkShts); g_MtbWkShts = null;
            if (g_MtbUI != null)
                Marshal.ReleaseComObject(g_MtbUI); g_MtbUI = null;
            if (g_MtbProj != null)
                Marshal.ReleaseComObject(g_MtbProj); g_MtbProj = null;

            if (g_MtbApp != null)
            {
                g_MtbApp.Quit();
                Marshal.ReleaseComObject(g_MtbApp); g_MtbApp = null;
            }            
        }        
    }
}

I'm using:

Windows Server 2008 R2 Standard (SP 1)

IIS 7.5.7600.16385

Framework 4.0.30319

Visual Studio 2010 Version 10.0.30319.1

Minitab 16.1.0

Thank you, Pablo

هل كانت مفيدة؟

المحلول 2

Thanks Jlew for the link. It helped me to solve the problem by changing a register value from “Shared Section=1024,20480,768” to “Shared Section=1024,20480,2304” (3 times bigger) on this register key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems\Windows This value specifies a memory heap size when the user is not logged on. I guess it was not enough to handle all the MiniTab graphs.

Pablo

نصائح أخرى

Just a guess, based on something that happened to me ages ago:

For some reason, Minitab is displaying a modal error dialog of some kind. When you configure DCOM to launch as some user (not the interactive user), the process gets its own "windows station" which is not actually visible to you as the logged in user. So there is a dialog popped up somewhere invisible, waiting for input forever, hence the hang. Why the dialog is displaying is a different matter, likely a permissions issue. Sometimes, certain parts of the registry are available or not available in different activation contexts, for example.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top