MFC Activex Control - Failed to create control: Unspecified error
Hello,
I have created an activex control in MFC 8, VS - 2005 Beta 2, which hosts Windows Forms control in it. I have created it as per the article by Nicola (MFC 8 (VC++ 2005 and Windows Forms). When I test using the activex tester I get the message - Failed to create control: Unspecified error. When I refered this object in a html page using the object tag - It does not show the object. I have used the /clr option.
I noticed one more thing - When I comment out CWinFormsControl related code, the activex object displays on the html page. When I add the CWinformsControl code back, it does not even go into the OnInitDialog method of the activex control.
I am at a dead end here and any help on this subject will be appreciated.
Thanks,
[753 byte] By [
MadhuK] at [2007-12-16]
Hi Nikola!!!!
Thanks for your response. Originally i was having trouble displaying an activex control compiled with /CLR option. This got fixed after i installed VS 2005 CTP July 2005.
Now I have run into another problem. I have created a simple button control in .Net, just like what you did in your example. and an MFC ACtivex control is hosting it. I implemented the MFC activex control exactly like yours. The programme is erroring on the statement :
m_MyUc.CreateManagedControl(SW_SHOW, IDC_STATIC1, this);
Application popup: IEXPLORE.EXE - Application Error : The instruction at "0x0b1df88a" referenced memory at "0x00000000". The memory could not be "read". When I do a cancel to debug - it is pointing to occcont.cpp
BOOL CWnd::InitControlContainer(BOOL bCreateFromResource)
Also I am not able to debug my MFC code.
I would be very glad if you could give me pointers.!!!!Thanks again.
Madhu K.
Thanks for that!
I am trying to wrap a .Net controls as an MFC Active X with VS 2005, but I really dont know where to start... I have looked at Nicola's sample, but I do not know what parts will be useful to me. Any hints?
I am not sure what exactly you are trying to do. Do you already have MFC ActiveX control and you are trying to replace part of its UI with a WinForm control? I remember I looked into this scenario at some point and find it not possible to implement. Sorry I do not remember details.
If you are looking for a general way of wrapping Windows Form control as an ActiveX control, this task has nothing to do with MFC. It is general Winform/COM interop issue. Quickly searching web, I have found this example of doing this http://www.codeproject.com/cs/miscctrl/exposingdotnetcontrols.asp. I think it is the same to what you are trying to do.
Nikola
Hi,
I too have same problem. Failed to create control: Unspecified error.
Actually i registered my dll in ActiveX control Test container in the menu Registar Controls.
PleaSE tell me how to create the control. It is very urgent.
Thanks
Gugapriya Jagadeesan
When I select Common Language Runtime Support for this thing to work.
[code]
#using <System.dll>
#using <System.Security.dll>
[/code]
However it works in Normal dialog Based and SDI/MDI Applications. But in an ActiveX control it generates these warning.
[code]
c:\Adeel\Projects\Automation\DigitalCertificate\DigitalCertificateCtrl.cpp : warning C4793: 'virtual-call thunks are native with /clr' : causes native code generation for function 'COleControl::`vcall'{492}''
c:\Adeel\Projects\Automation\DigitalCertificate\DigitalCertificateCtrl.cpp : warning C4793: 'virtual-call thunks are native with /clr' : causes native code generation for function 'COleControl::`vcall'{496}''
Compiling resources...
Linking...
Creating library C:\Adeel\Projects\Automation\DigitalCertificate\Debug\DigitalCertificate.lib and object C:\Adeel\Projects\Automation\DigitalCertificate\Debug\DigitalCertificate.exp
mfcm80ud.lib(postrawdllmain.obj) : warning LNK4099: PDB 'mfcm80ud.i386.pdb' was not found with 'c:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\mfcm80ud.lib' or at 'c:\Adeel\Projects\Automation\DigitalCertificate\Debug\mfcm80ud.i386.pdb'; linking object as if no debug info
mfcm80ud.lib(postdllmain.obj) : warning LNK4099: PDB 'mfcm80ud.i386.pdb' was not found with 'c:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\mfcm80ud.lib' or at 'c:\Adeel\Projects\Automation\DigitalCertificate\Debug\mfcm80ud.i386.pdb'; linking object as if no debug info
[/code]
As a result the control does'nt get loaded in OLE container or ActiveX test container. It generates error. Can someone help me with this?