Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 834615 - Last Review: November 27, 2007 - Revision: 3.6
You may receive a "TargetInvocationException" error message when you delete the UserControl1 user control from a Windows Service project in a Visual Basic .NET or Visual Basic 2005 application
When you try to delete the
UserControl1 user control from Component Designer in a Windows Service project, and the
UserControl1 user control contains a Windowless ActiveX control, you may receive the following error message:
The following exception has occurred:
TargetInvocationException: Unable to get the window handle for the 'AxMSFlexGrid' control. Windowless ActiveX controls are not supported.
The
UserControl1 user control that contains the Windowless ActiveX controls is not currently supported in a Windows Service project.
This behavior is by design.
Steps to reproduce the problem
- Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005.
- Create a new Microsoft Visual Basic .NET or Microsoft Viusal Basic 2005 Windows Service project that is named WindowsService1. By default, the project is created under the solution that is named WindowsService1.
- Add a Windows Control Library project that is named WindowsControlLibrary1 to the WindowsService1 solution.
- Open the Customize Toolbox dialog box.
To do this in Visual Studio .NET 2002, right-click Components under Toolbox, and then click Customize Toolbox.
To do this in Visual Studio .NET 2003, right-click Components under Toolbox, and then click Add/Remove Items.
To do this in Visual Studio 2005, right-click Components under Toolbox, and then click Choose Items. - In the Customize Toolbox dialog box, click to select the Microsoft FlexGrid Control, version 6.0 check box on the COM Components tab, and then click OK.
- On the UserControl1.vb[Design] page, click the Toolbox, click the Components tab, and then click Microsoft FlexGrid Control, version 6.0.
- On the Build menu, click Build Solution.
The Windowscontrollibrary1.dll file is created. - In Solution Explorer, double-click the Service1.vb file under the WindowsService1 project.
- Add the UserControl1 user control to the Service1.vb[Design] page.
If you are using Visual Studio .NET 2002, follow these steps:- Under Toolbox, click Components, right-click Components, and then click Customize Toolbox. The Customize Toolbox dialog box appears.
- In the Customize Toolbox dialog box, click the .NET Framework Components tab, and then click Browse to locate the WindowsControlLibrary1.dll file that you created in step 7.
- Click the WindowsControlLibrary1.dll file, and then click Open.
- Click OK to close the Customize Toolbox dialog box.
- From the Components tab of the Toolbox, drag the UserControl1 user control to the Service1.vb[Design] page.
Note If you receive the following error message, click OK to close the error message dialog box:---------------------------
Microsoft Development Environment
---------------------------
The .NET assembly 'Interop.MSFlexGridLib' could not be found.
---------------------------
OK
---------------------------
- From the Components tab of the Toolbox, drag the UserControl1 user control to the Service1.vb[Design] page.
If you are using Visual Studio .NET 2003, click the My User Controls tab on the Toolbox, and then click UserControl1. - Try to delete the UserControl1 user control from the Service1.vb[Design] page.
You may receive the error message that is mentioned in the "Symptoms" section.
For additional information, visit the following Microsoft Developer Network (MSDN) Web sites:
APPLIES TO
- Microsoft Visual Basic .NET 2003 Standard Edition
- Microsoft Visual Basic .NET 2002 Standard Edition
- Microsoft Visual Basic 2005
| kbvs2005swept kbvs2005applies kbtoolbar kbservice kbmsg kbdll kbcontrol kbuser kbprb KB834615 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate