在Windows Server 2016中使用ATL崩溃动态创建控件 [英] Create controls dynamically with ATL crashes in windows server 2016
问题描述
我们在VS 2005上构建了MMC管理单元代码。管理单元具有从CSnapInPropertyPageImpl< t>派生的很少的属性页面。
这是类定义的代码片段
类TTreeConfigPage02:public CSnapInPropertyPageImpl< ttreeconfigpage02>
这是在Windows 10上工作正常但在行崩溃的代码片段
spHost-> AttachControl(m_grid,m_wndGrid);
Windows Server 2016中的
。它会立即抛出错误。当我们在对话框中静态添加相同的ActiveX组件时(在对话框 - >右键碰撞 - >插入ActiveX组件)工作正常。
We have a MMC Snap In Code built on VS 2005. The snap in has few property pages derived from CSnapInPropertyPageImpl<t>
Here is the code snippet for the class definition
class TTreeConfigPage02 : public CSnapInPropertyPageImpl<ttreeconfigpage02>
Here is the code snippet which works fine on Windows 10 but crashes at line
spHost->AttachControl(m_grid, m_wndGrid);
in Windows Server 2016. It immediately throws a error. The same ActiveX component when we add statically in dialog (On a dialog -> Right clink -> Insert ActiveX Component) works fine.
// initialize ATL ActiveX hosting
AtlAxWinInit();
// create the control (will fail if not registered) IDC-> Of a Picture cotrol
CWindow dlgWin = GetDlgItem(IDC_SELECT_GRID_HOST_FOL); // get host window
m_grid.CreateInstance(__uuidof(FiltFolder)); //FiltFolder is a Composite Control
ATLASSERT(m_grid != NULL);
RECT rcWind;
dlgWin.GetWindowRect(&rcWind);
ScreenToClient(&rcWind);
m_wndGrid.Create(m_hWnd, rcWind, NULL, WS_CHILD | WS_VISIBLE, 0, IDC_SELECT_GRID_FOL);
// attach the control to the host window
CComPtr<IAxWinHostWindow> spHost;
m_wndGrid.QueryHost(&spHost);
spHost->AttachControl(m_grid, m_wndGrid);
IUnknown* pUnk;
m_grid.QueryInterface(IID_IUnknown, &pUnk);
DispEventAdvise(pUnk);
关于为什么它只是在Win Server 16中失败的任何想法。
在此先感谢
我尝试过:
尝试其他选择以及下面的链接中提到的。什么都没有用
https://jeffpar.github.io/kbarchive/kb/218/Q218442/
Any thoughts on this as to why it is only failing in Win Server 16.
Thanks in advance
What I have tried:
Tried other option as well as mentioned in the link below. Nothing worked
https://jeffpar.github.io/kbarchive/kb/218/Q218442/
推荐答案
你注册了COM吗? Windows Server 2016上带有regsvr32命令的server / dll?
Did you register the COM server/dll with regsvr32 command on Windows Server 2016?
这篇关于在Windows Server 2016中使用ATL崩溃动态创建控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!