如果 Windows 版本 >= Server2008,.NET Interop 应用程序会损坏

发布于 2024-08-09 04:30:13 字数 4651 浏览 4 评论 0 原文

我们有一个较大的 32 位 MFC/COM 应用程序,它使用互操作调用 .NET dll。它在 2k(服务器和客户端)、XP 和 Windows 上运行良好。 Win2k3。我们已经在 Server 2008 和 Server 2008 上对其进行了测试。 Win7&它挂着 ntdll.dll 中出现异常 0xc0000005。 尝试从 COM 应用程序中的菜单运行它后,当我们关闭 COM 应用程序时,它也会挂起。 有谁知道 2008 年和 2008 年有什么具体问题吗?互操作,说一些与 UAC 或权限(或其他任何东西!)有关的事情? .NET 应用程序调用 COM 应用程序,并由它启动,但到目前为止它工作正常,没有明显的错误。我希望我可以提供错误的更多详细信息,但唯一具体的信息似乎是事件日志错误。顺便说一下,COM 应用程序可以在 Win2008 上完美运行。 .NET 应用程序不适用于 32 或 64 位版本的 Win2008。 如果人们告诉我他们想要什么,我将提供更多信息...

对以下评论的回应:

它现在在 .NET 3.5 上编译(并且使用版本 2 编译),两者都在 2008 年的机器上(刚刚查看) 。我也使用来自适当的 .NET 安装的 gacutils 等版本

更多评论:

它是为 x86 编译的。就 UAC 而言 - 我不熟悉它的编程方面,我认为有一个 .NET API,但是是的,访问被拒绝。我将不得不进一步了解 UAC 学习曲线(这也让我想知道我在做什么可能需要提升权限,也许 Win32 编程要求它们)。我已经看到 此博客条目,其中讨论了使用清单。当我回到我的工作机器时(22 日休息一天) pm)我将发布一个调用堆栈和我能想到的其他任何可能有帮助的事情。感谢您的兴趣,人们

一些代码:

MFC/COM应用程序中的调用代码:

void CMainFrame::OnTransportResourcetrackingGanntchart()
{
    HRESULT hr = m_spGant.CreateInstance(__uuidof(Fgant::Control_Gant));
    ASSERT(SUCCEEDED(hr));
    m_spGant->Control_Run();
    //m_spGant = NULL;
}


Relevant code in FGant.dll 
using GlobvarsLib;//as well as the .NET declarations
 // COM dll containing system-wide properties imported using tlbimp
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
    [Guid("A4586AC8-BC1D-4cbe-83CA-4F2A56F0E964")]
    public interface IGantControl
    {
        /// <summary>
        /// method to run Fgant from external application
        /// </summary>
        void Control_Run();
    }

    /// <summary>
    /// Control_Gant constructor
    /// </summary>
    [ClassInterface(ClassInterfaceType.None)]
    [Guid("BC4CF302-A973-445d-82BE-1BF0B4873D90")]
    public class Control_Gant : IGantControl
    {
        /// <summary>
        /// Default constructor
        /// </summary>
        public Control_Gant() { }

        [STAThread]
        void IGantControl.Control_Run()
        {
            Fgant gantt = new Fgant(true); //Inits Component,Calls PlotGantt with default date values
            DateTime startdate, enddate;
            int MinsLength = 15;
            startdate = gantt.Start;
            enddate = gantt.End;
            //Add 23:59:59 to enddate
            enddate = enddate.Date.AddSeconds(86399);
            gantt.BlobDivisor = 24;
            gantt.CentreGantt();
            gantt.VehicleRadioChecked = true;
            try
            {
                ResPlot res = new ResPlot(gantt.ResType());
                //See below for PlotGantt code
                gantt.PlotGantt(startdate, enddate, MinsLength, ResPlot.WhereClause, ResPlot.TitleString, ResPlot.ResType);
                Application.EnableVisualStyles();
                GlobalClass pGlobal = new GlobalClass();
                IntPtr pWnd = (IntPtr)pGlobal.get_MainWindow();
                NPlot.PointPlot.Active_Handle = pWnd;
                SwiftWindow sw = new SwiftWindow(pWnd);//'MainFrame' app window
                gantt.Show(sw);
            }

    PlotGantt snippet:
    GantUtils g = new GantUtils();  //Class that contains the DB conn.string from Globvarslib(i.e from the calling app)
            string ConnString = g.DBString;

            string selectCommand = String.Concat("SELECT StartDateTime, EndDateTime, Stage.Description, ", ResourceName, ", LoadNumber ",
                                                        Rigid, " , ROUND(((DATEDIFF(minute,StartDateTime,EndDateTime))/", MinsLength.ToString(), " ),0) AS \"StageDiff\" ",
                                                        ", '1' AS \"Orig_Row\", Stage.Type AS \"SType\" FROM Stage ", selectString, " AND StartDateTime >= '",
                                                        Startdt.ToString(), "' AND EndDateTime <= '", Enddt.ToString(), "' ORDER BY ", ResourceName, Rigid, ",Stage.Type, StartDatetime,EndDateTime");
         //   MessageBox.Show(selectCommand);
                OleDbDataAdapter dataAdapter = new OleDbDataAdapter(selectCommand, ConnString);
            dataAdapter.Fill(table);


    DBString code calling Glovarslib(In GantUtils()):
    public string ConnectionString()
    {
        GlobalClass pGlobal = new GlobalClass();
        string conn_string = "FILE NAME=" + pGlobal.UDLRootPath+pGlobal.SupportDir + SwiftDatabaseUDL;
        return conn_string;
    }

我怀疑它可能会在获取conn_string(它所做的涉及互操作的第一件事)或在数据库上执行SELECT时失败

(调用堆栈如下)

We have a largish 32-bit MFC/COM app that calls a .NET dll using interop. It works fine on 2k(server & client), XP, & Win2k3. We've been testing it on Server 2008 & Win7 & it hangs with
exception 0xc0000005 in ntdll.dll.
After attempting to run it from the menu in the COM app, when we close the COM app it hangs as well.
Does anyone know of any specific issue with 2008 & interop, say something to do with UAC or permissions( or anything else!)?
The .NET app makes calls to the COM app, as well as being started by it, but its worked fine up to now, with no visible errors. I wish I could give more detail of the error, but the only concrete info seems to be the event log error. The COM app runs perfectly on Win2008, by the way. The .NET app doesn't work on 32 or 64 bit versions of Win2008.
I'll supply more info, if people tell me what they want...

Response to comments below:

Its compiled on .NET 3.5 now (& was compiled with version 2) both of which are on the 2008 machine (just looked). I'm using the version of gacutils etc. from the appropriate .NET install as well

More comments:

Its compiled for x86. As far as UAC is concerned - I'm not familiar with the programming side of it,I presume there's a .NET API for it, but yes, Access Denied. I'm going to have to get on the UAC learning curve a bit more( and it also makes me wonder what I'm doing that could require elevated privs,perhaps the Win32 prog is demanding them).I've seen this blog entry which talks about using manifests .When I get back to my work machine(been off for day back 22nd p.m.) I shall post a call stack & anything else I can think of that might help. Thanks for your interest, people

Some code:

The calling code in the MFC/COM app:

void CMainFrame::OnTransportResourcetrackingGanntchart()
{
    HRESULT hr = m_spGant.CreateInstance(__uuidof(Fgant::Control_Gant));
    ASSERT(SUCCEEDED(hr));
    m_spGant->Control_Run();
    //m_spGant = NULL;
}


Relevant code in FGant.dll 
using GlobvarsLib;//as well as the .NET declarations
 // COM dll containing system-wide properties imported using tlbimp
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
    [Guid("A4586AC8-BC1D-4cbe-83CA-4F2A56F0E964")]
    public interface IGantControl
    {
        /// <summary>
        /// method to run Fgant from external application
        /// </summary>
        void Control_Run();
    }

    /// <summary>
    /// Control_Gant constructor
    /// </summary>
    [ClassInterface(ClassInterfaceType.None)]
    [Guid("BC4CF302-A973-445d-82BE-1BF0B4873D90")]
    public class Control_Gant : IGantControl
    {
        /// <summary>
        /// Default constructor
        /// </summary>
        public Control_Gant() { }

        [STAThread]
        void IGantControl.Control_Run()
        {
            Fgant gantt = new Fgant(true); //Inits Component,Calls PlotGantt with default date values
            DateTime startdate, enddate;
            int MinsLength = 15;
            startdate = gantt.Start;
            enddate = gantt.End;
            //Add 23:59:59 to enddate
            enddate = enddate.Date.AddSeconds(86399);
            gantt.BlobDivisor = 24;
            gantt.CentreGantt();
            gantt.VehicleRadioChecked = true;
            try
            {
                ResPlot res = new ResPlot(gantt.ResType());
                //See below for PlotGantt code
                gantt.PlotGantt(startdate, enddate, MinsLength, ResPlot.WhereClause, ResPlot.TitleString, ResPlot.ResType);
                Application.EnableVisualStyles();
                GlobalClass pGlobal = new GlobalClass();
                IntPtr pWnd = (IntPtr)pGlobal.get_MainWindow();
                NPlot.PointPlot.Active_Handle = pWnd;
                SwiftWindow sw = new SwiftWindow(pWnd);//'MainFrame' app window
                gantt.Show(sw);
            }

    PlotGantt snippet:
    GantUtils g = new GantUtils();  //Class that contains the DB conn.string from Globvarslib(i.e from the calling app)
            string ConnString = g.DBString;

            string selectCommand = String.Concat("SELECT StartDateTime, EndDateTime, Stage.Description, ", ResourceName, ", LoadNumber ",
                                                        Rigid, " , ROUND(((DATEDIFF(minute,StartDateTime,EndDateTime))/", MinsLength.ToString(), " ),0) AS \"StageDiff\" ",
                                                        ", '1' AS \"Orig_Row\", Stage.Type AS \"SType\" FROM Stage ", selectString, " AND StartDateTime >= '",
                                                        Startdt.ToString(), "' AND EndDateTime <= '", Enddt.ToString(), "' ORDER BY ", ResourceName, Rigid, ",Stage.Type, StartDatetime,EndDateTime");
         //   MessageBox.Show(selectCommand);
                OleDbDataAdapter dataAdapter = new OleDbDataAdapter(selectCommand, ConnString);
            dataAdapter.Fill(table);


    DBString code calling Glovarslib(In GantUtils()):
    public string ConnectionString()
    {
        GlobalClass pGlobal = new GlobalClass();
        string conn_string = "FILE NAME=" + pGlobal.UDLRootPath+pGlobal.SupportDir + SwiftDatabaseUDL;
        return conn_string;
    }

I suspect it could be failing either as soon as it gets the conn_string(1st thing it does involving interop) or when it does the SELECT on the database

(Call stack to follow)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文