Gotchas- InfoPath 2010


I have encountered the following error “Microsoft InfoPath has stopped working” while trying to open VSTA (Microsoft Visual Studio Tools for Applications) via the InfoPath form. I was trying to leverage ‘Edit from Code’ option available in InfoPath. I tried  troubleshooting for a while, searched for errors in my event log and researched a bit to find a solution. But failed! The following solution did work for me, but there could be hundred different reasons why it failed on you. Hopefully the following solution saves some time for you

Solution: For unknown reasons VSTA failed to locate the code that it was referencing previously. I have deleted the references to code using ‘Remove Code’ option in InfoPath and reattached the code and everything worked fine seamlessly! This basically involves navigating to Developer>Language> Form Options> Programming> Remove Code. After completing this, point ‘Project Location’ to where the form code existed before and hit ‘OK’.


Task failed because “sgen.exe” was not found, or the .NET Framework SDK v2.0 is not installed.  The task is looking for “sgen.exe” in the “bin” subdirectory beneath the location specified in the SDKInstallRootv2.0 value of the registry key HKEY_LOCAL_MACHINESOFTWAREMicrosoft.NETFramework.  You may be able to solve the problem by doing one of the following:  1.) Install the .NET Framework SDK v2.0.  2.) Manually set the above registry key to the correct location.  3.) Pass the correct location into the “ToolPath” parameter of the task


This error started coming up when I added web reference to VSTA and started to build the application. The whole error is all about the setting in the project settings “Generate Serialization Assembly” this setting was initially “Auto” so I have set this to “Off” and the build was successful. When the the setting was set to “Auto” the VSTA was trying to find sgen.exe (XML Serializer Generator –  this tool creates an XML serialization assembly for types in a specified assembly in order to improve the startup performance of a XmlSerializer when it serializes or deserializes objects of the specified types).


I have encountered the following error while I tried to run my VSTA that loads my InfoPath form to debug. “InfoPath cannot open files selected forms because of an error in the form code. Policy settings prevent opening Internet forms with managed code. To fix this problem, contact your system administrator


It appears that some forms need to be in full trust if they contain managed code. I gave the form ‘Full trust’. This scenario works for me and might not fit well with your environment, please be cautious when using this option as this will enable InfoPath form to access files and settings on the computer.


Sandbox Solutions – SharePoint 2010

You must have come to this post searching for ‘Sandbox Solutions’ in one of your favorite search engines. Good that you are at the right place to know in and out of Sandbox solutions.

Why do I need a Sandbox Solution?

Scenario 1# Sometimes I am a dumb programmer.
Programming is like hand writing. The start is the most important. The better the writing habbits are, the better your wrting style is.  Even for a programmer, if good coding habits are not adopted/exercised right from the beginning, he would some how mange to get the stuff working, but he will never realise that its not he best way to do. Especially with SharePoint even after taking a great care in disposing SharePoint objects there might be  chances of bad coding practices to creep in, leaving some objects undisposed which can potentially throttle the server with high memory usage.

You might be thinking of asking me why is Garbage Collector not taking care of this? For instance, when using objects of type ‘SPSite’ or ‘SPWebapplication’, part of the actions do not run under managed code at all. You shouldn’t be surprised to know that CRUD(create, read, update, delete) operations to ‘content’ database are performed by a COM component which does not run managed code and the ‘Garbage Collector’ is not even aware of these objects. This is one reason why you have to dispose your SharePoint objects promptly. To handle situations like this  ‘Sandbox Solution’ is the answer.

Scenario 2# I hate my administrator
As a developer, once you finish your development and have your solution package ready you are eager to deploy it to staging or production. Its not very uncommon to hear from your administrator asking you to come back. You will be pissed off even more if you are a site collection administration and not able to deploy your own solutions to your site with out administrator’s intervention. ‘Sandbox Solution’ is the answer.

Scenario 3# I hate my developer
As an admin, I really get scared when my developers approach and say “The solution package is ready. Can you please deploy that to production?” At that moment, I have so many things going on in my mind. Will his solution get my portal down? I am not sure what his code does, Will it delete all my existing webapplications? Is his code accessing local file system and exposing sensitive data?  Even if I have tools like SPDispose check tool that can check memory leaks, there are very low or no chances of validating his code against any bad practices. ‘Sandbox Solution’ is the answer.

Scenario 4# My client always has a big NO!
For instance consider yourself as a service provider or a product development company. When the clients buy our product/SharePoint solution, what is the guarantee that you don’t have malicious code with in your solution that could access their local files or sensitive data? How can they trust that your code is not consuming too much of their server resources? There might be a situation where the client might not even let you change their folder/file structure, which in many cases the developer becomes handicapped with out being able to change webconfig, or add files to 14/12 hive. ‘Sandbox Solution’ is the answer.

Fortunately to handle situations like above, Microsoft has introduced ‘Sandbox Solutions’. So what is a Solution? Typically development is like solving a puzzle, when you finished solving and got the peices together, its time to pack or wrap it up. So you develop and pack all your folders, files together in file with .wsp extension as a solution to your client’s requirements. So your client has SharePoint installed and needs to deploy this solution in their farm. Once deployed, all these files get into those folders that were created while installing SharePoint. SharePoint picks these up when the end user requests for them via the application built. Contine reading to understand the concept of solution packaging and how ‘Sandbox Solutions’  provide solutions to the above mentioned scenarios….