Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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);






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/
Posted
Updated 16-Apr-19 22:37pm
Comments
Richard MacCutchan 17-Apr-19 4:36am    
"It immediately throws a error."
Please edit your question and add full details of the error; people here cannot guess what happens.
sumangvs 17-Apr-19 6:15am    
My Apologies Richard , but , it just crashes with access violation. I shall try to put the call stack
sumangvs 17-Apr-19 7:10am    
In the meanwhile I created a Sample Dialog based application with ALT Support and created the ActiveX Component dynamically. It worked fine.

Now is this something to do with MMC SnapIn now ?

1 solution

Did you register the COM server/dll with regsvr32 command on Windows Server 2016?
 
Share this answer
 
Comments
sumangvs 17-Apr-19 6:11am    
yes , it is registered. As I mentioned it works fine in Win 10 Box. It is something to do with Windows Server 2016. I checked the return value of m_grid.CreateInstance(__uuidof(FiltFolder)); //FiltFolder is a Composite Control
It returns S_OK.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900