Remove Existing InfoPath VSTA Project
Posted by Steve Pietrek on April 15, 2008
This morning I was creating an InfoPath 2007 form and wanted to add an OnChanged event handler for a dropdownlist control. Bear in mind this is my first foray into InfoPath programming – never had a need previously. I right-clicked the dropdownlist control and selected Programming – Changed Event. Visual Studio Tools for Applications fired up but the project was VB.NET. No offense to VB but I would rather program in C#. Need to find a way to remove the current VB project and create a C# one instead.
The first task was to ensure all new form projects would default as C# projects. To change the default:
- Open Tools – Options
- Click the Design tab
- For the “Programming language when designing forms that run in InfoPath” option, select C#.
- For the “Programming language when designing for InfoPath and InfoPath Forms Services” option, select C#.
- If needed, you can also change the default project location – possibly to help with version control.
- Click the OK button to save.
Now that all new forms will default to C#, I need to find a way to remove the current project. Thinking I could solve the issue by cutting off the head, I deleted the project in the C:\Documents and Settings\Administrator\My Documents\InfoPath Projects\ExpenseReport\ folder. Unfortunately, after deleting the directory, when I accessed the “Changed Event” event, I received the following error:
“InfoPath cannot add the event handler”
After some digging, to remove InfoPath code, or specifically in my case, unhook the project:
- Open Tools – Form Options
- Select the Programming category
- Click the Remove button and select Yes
- Click OK




Andy said
Thanks for this nugget of advice – I did *exactly* the same as you during my first attempt at an Infopath form!