System.IO.FileNotFoundException when creating SPSite objects using the SharePoint object model
August 22, 2008 6 Comments
This is one of the interesting errors that we encountered recently. A console application was developed for content migration from a file share to SharePoint with an Excel file for mapping the files to specific content types. The application was run on our test environment and everything seemed to work fine. Of course we wanted to run this over the weekend. Time for easy deployment right since it is all tested and ready right? Wrong! When deploying to the server we came across this error
“Provider not registered in this environment” . After a bit of googling we realized the issue. Our test environment was running a 32 bit SharePoint installation, whereas the production version was 64 bit. Since we were using Jet drivers to connect to the Excel spreadsheet, we had to retool our application or target a specific architecture(since 32 bit drivers are available on the server). We chose the second option. We set the target platform to x86 and deployed it on production.
Update: Here is the forum post with the link to the solution. Scroll down to the 3rd comment with a link to the vbtips site http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=125207&SiteID=1
Now we were seeing the dreaded System.IO.FileNotFoundException when creating SPSite objects in our code.
Apparently setting the target architecture to x86 and running the code on a x64 SharePoint installation, throws the FileNotFoundException. We changed the target architecture back to the default setting and had to retool the code to read the mappings using an Xml export.