FileNotFound Exception with Sharepoint 2010 with the SPSite Constructor - sharepoint

I try to instantiate a instance of SPSite on the farm server in a console app and I give in parameter the whole website (http://sp2010/). I also made sure that the account running MyApp.exe is Site Collection Administrator.
However, I can't make an instance of SPSite whatever I am trying to do. I always gives back "FileNotFoundException".
Anyone got an idea?
StackTrace:
System.IO.FileNotFoundException: The Web application at http://localhost/sandbox could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application. at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri, Boolean contextSite, SPUserToken userToken) at Microsoft.SharePoint.SPSite..ctor(String requestUrl) at Conchango.xyzzy.GetExistingDocument(String minId, String maxId, String titleFilter) in C:\Documents and Settings\Paul\My Documents\Visual Studio 2005\Projects\xyzzy\BDC_DocReview\BDC_DocReview\DocReviewFacade.asmx.cs:line 69
When i run this app using the App Pool Identity account it works fine. However when I run this console app using a different user that is a Site Collection Admin, Farm Admin, has dbowner rights on the content database for the Sharepoint Web application.. it does not work right and gives me this Filenot Founf Exception.
The Console app uses .Net Framework 3.5 and x64 as the CPU platform.
Again this works if i use the App Pool Identity Account, but not with any other account

User running the console application needs to have at least read permission to the SharePoint databases, otherwise you will see this kind of errors

I had this problem and solved it for my console application by changing the "Platform target:" option on the "Build" properties page to "Any CPU".

NET framework you used is not matched with SharePoint 2010 Server,for example .NET 4.5 is applied, the exception will be thrown , change to .NET 3.5 , fix your issue.

If you are using MSTest, make sure that the Test Runner matches the platform you are using. See this SO post regarding targeting MSTest for your current platform.

I had to make my Windows Forms test application .NET 3.5 instead of .NET 4.5.

SP 2010 works only on x64 mode. So change your project platform target to x64.
If your service is already running in IIS, than make sure that your app pool has the property Enable 32 bit applications set to false.

Related

IIS Express Debugging No Longer Working

I'm using IIS Express with Visual Studio 2013 on Windows 8.1 x64 for a WebAPI 2 application (all en-US here). This worked just fine roughly a month ago, but now I'm getting errors when attempting to debug the application.
If I do not run VS as admin (again, didn't need to do this before), I get:
A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
Additional information: Access to the path 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\~AspAccessCheck_c00414062044.tmp' is denied.
A second error occurs after this, or it will be the first error if I run VS as Administrator:
A first chance exception of type 'System.Globalization.CultureNotFoundException' occurred in mscorlib.dll
Additional information: Culture is not supported.
If I run the same WebAPI application from WebMatrix 3, it runs without errors (with or without running 'as Admin').
Project IIS config settings:
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort>46435</IISExpressSSLPort>
<IISExpressAnonymousAuthentication>enabled</IISExpressAnonymousAuthentication>
<IISExpressWindowsAuthentication>disabled</IISExpressWindowsAuthentication>
<IISExpressUseClassicPipelineMode>false</IISExpressUseClassicPipelineMode>
I also have the application running on http://localhost:46436.
What I also find really strange is that the project properties show "IIS Express" and to use a URL of http://localhost:46436/, but in the project file I'm seeing:
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>46435</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:46436</IISUrl>
That may explain my access denied. Regardless if I unset, save, and re-set to use IIS Express (storing it for all users), the <UseIIS> property is set back to true.
EDIT: It looks like "Use IIS" is normal. I created a new WebAPI 2 project as a test. It ran fine under IIS Express OOTB.
I also had this issue. Ended up having to right click the folder in question and add access for the IIS_IUSR account.
If this isn't causing critical errors, you can also disable break mode for this sort of issue via Debug -> Options -> Debugging and check Enable Just My Code (Managed Only)
I updated all of the packages via the 'Manage NuGet Packages' console, and it started working.

Cant get a basic ASP.Net 5 website working on Azure

I have a very basic ASP.Net 5 application that I created following this guide https://www.asp.net/vnext/overview/aspnet-vnext/create-a-web-api-with-mvc-6, and it works grate from VS.
However I cant get that to work on azurewebsites. I keep getting the yellow runtime error page on the browser and this exception on the log file:
<EventData>
<Data>3005</Data>
<Data>An unhandled exception has occurred.</Data>
<Data>11/22/2014 9:39:33 PM</Data>
<Data>11/22/2014 9:39:33 PM</Data>
<Data>9e1c1ecb36f647ddb1f4b1856b2a105c</Data>
<Data>1</Data>
<Data>1</Data>
<Data>0</Data>
<Data>/LM/W3SVC/46675609/ROOT-1-130611659736590153</Data>
<Data></Data>
<Data>/</Data>
<Data>D:\home\site\wwwroot\</Data>
<Data>RD00155D431959</Data>
<Data></Data>
<Data>21084</Data>
<Data>w3wp.exe</Data>
<Data>IIS APPPOOL\glMigrations</Data>
<Data>DirectoryNotFoundException</Data>
<Data>
Couldn't find package 'KRE-CoreCLR-x86.1.0.0-beta1'. Locations probed:
D:\home\site\approot\packages\Migrations\1.0.0\packages\KRE-CoreCLR-x86.1.0.0-beta1
D:\home\site\approot\packages\Migrations\packages\KRE-CoreCLR-x86.1.0.0-beta1
D:\home\site\approot\packages\packages\KRE-CoreCLR-x86.1.0.0-beta1
D:\home\site\approot\packages\KRE-CoreCLR-x86.1.0.0-beta1
D:\home\site\packages\KRE-CoreCLR-x86.1.0.0-beta1
D:\home\packages\KRE-CoreCLR-x86.1.0.0-beta1
D:\packages\KRE-CoreCLR-x86.1.0.0-beta1
at AspNet.Loader.KRuntimeLocator.GetPathToSpecificKrePackage(DirectoryInfo appPhysicalPath, String krePackage)
at AspNet.Loader.KRuntimeLocator.LocateKRuntime(MapPathHelper mapPathHelper, Boolean& isCoreClr, String relativeAppBasePath)
</Data>
I tried with the core and the full version and got the same results.
Any advice will be appreciated.
I came across the same error when deploying to a local IIS server. The issue turned out to be caused by the project build settings not having "Produce outputs on build" ticked. I've just tried running my test project on Azure Website and managed to get it working.
I also had another issue deploying to the default "Free" plan website, as I was using the X64 KRE and only the "Basic" and "Standard" plans support X64.
I wrote a Blog Post on how I got ASP.NET 5.0 working on local IIS, which I've updated with the Azure website findings, as my rep here is not high enough to post pictures.
Edit:
In case the link to my blog post breaks the following is a basic description of the steps I took to get ASP.Net 5.0 running on IIS and then Azure Websites
Created an ASP.NET 5.0 Site using the Visual Studio 2015 Preview template running on Windows 10 Technical preview
For the local IIS I then ensured that IIS had all the required features, which you can obviously skip for azure
I then changed the "Build Settings" of the project to enable "Produce Outputs on Build" for both "Debug" and "Release" configurations
Next I updated the project.json file to use the url I had configured in IIS, again this may not be necessary for azure
I then created a Publishing profile to the local IIS server, which worked nicely.
Having seen this post, I then attempted to deploy to Azure by simply creating a new publishing profile targeting Azure Websites
I came across a similar error at this point, as I was targeting the X64 KRE, and the default Azure Website had been created as a "Free" site which does not support X64.
I then changed the Azure Website to the "Basic" plan, and enable X64 cpu.
Finally I redeployed using the earlier created Azure Publishing profile, Which this time resulted in a working site

IIS Error - It is not possible to run two different versions of ASP.NET

I'm getting this error thrown repeatedly on my IIS 6.0 server:
It is not possible to run two different versions of ASP.NET in the
same IIS process. Please use the IIS Administration Tool to
reconfigure your server to run the application in a separate process.
However, I ran an IIS MetaBase Analyzer to view all AppPools and AspNetVersions they're running and do not see any AppPools running different versions of AspNet. Is this a bug in IIS or is there definitely an AppPool running multiple versions of AspNet?
Thanks
Although it's an old question, for the benefit of future users who visit this yet unanswered question, here is the solution that worked for me.
In my case, the following worked.
Symptom :
The ASP.NET tab, for the "Default Website" node of the IIS Admin was showing a version of 1.1.
The ASP.NET tab, for my virtual directory application, was showing a version of 2.0 (which is the right one for my application).
Solution :
I changed the first one from 1.1 to 2.0. The application worked.
Cause :
The cause, however, seems "mysteriously unrelated", as it often happens in Windows. It was working fine with the same old (different) settings until a week back. What happened during the week, was that the machine A running the web server for my web application, had to unjoin a domain B and join another domain C, because the primary domain controller on B failed and had to be replaced with C. Why on earth would that affect IIS Admin or the web application hosted on A, and why it should generate this particular error is beyond me. Such a cause for this error seems undocumented.
It is not possible to run two different versions of ASP.NET in the same IIS process. This would mean you have multiple applications (either sites or virtual directories) using the same appPool, but one of these sites/applications has a different .NET version setting in the .NET tab. You would have to create another appPool to use different .NET versions.
To create another appPool and associate it to your application do (Windows Server 2003):
1.Click Start, point to All Programs, point to Administrative Tools, and then click Internet Information Services (IIS) Manager.
2.In Internet Information Services (IIS) Manager, expand , right-click Application Pools, point to New, and then click Application Pool
3.Right-click on application that uses a different .NET version and click on Properties
4.On menu Virtual Directory choose in the item Application Pool the application pool that you created in point 2.
Regards!

WebApplication moss feature throws FileNotFound on one environment

I developed a certain feature at web application scope, I've deployed it in my development computer, activated it and it worked fine.
Once I've deployed it in out Test environment and tried to activate it, it throws "File Not Found".
The main difference between the servers which I think of is that the Central Admin in the Test env. is not a front-end, while in my dev computer everything is hosted on the same computer.
I think it has something to do with the feature trying to reach "propeties.Feature.Parent as SPWebApplication" (I can't debug the code in the test environment)
Any ideas ?
Thanks in advanced.
Ok, this is the second time I’ve had this problem, so I’m going to
blog about it so maybe I’ll remember next time. If you’re using VS
2010 and developing outside of IIS (console application in my case),
you need to make sure your project is not targeting the x86 Platform.
Go to your Project Properties, click the Build tab, and make sure the
Platform target dropdown is set to x64 (or Any Platform). Another less
than helpful error…
From FileNotFound Exception when creating SPSite or getting reference to SPWebApplication (SharePoint 2010)
Also see this post: FileNotFoundException with the SPSite constructor

IIS7 Authentication problem

I have deployed a web site to a Win 2008 Web server with IIS7. The site works fine on a Win 2003 Standard server with IIS6. On the 2008 box, whenever I request a page (htm or aspx) from a folder named Reports, I get challenged with the Windows Authentication dialog box.
I have Anonymous Authentication and Forms Authentication enabled on the site. I applied Full Control permissions to the root of the site for both NETWORK SERVICE and IIS_IUSRS, but that hasn't make a difference.
Like a previous post already mentioned, here are the detailed steps to fix this:)
If there is a folder in the application named "Reports" and SQL Server Reporting Services are installedon the server, then Reporting Services Virtual Directory folder that is also named "Reports" will be in conflict with the application "Reports" folder.
To fix this open Reporting Services Configuration Manager (Start->All Programs->MS SQL Server->Configuraton Tools) and change the Virtual Directory under the "Report Manager URL" in the menu on the left.
Did you install MSSQL Reporting Services on your new machine? It'll use the Reports folder for the reporting toolkit (default setting) and under MSSQL 2008 you can't enable anonymous Access out of the box.
whats is the authentication mode in your web.config, verify that is not in Windows
<authentication mode="Windows" />
also be sure to disable integrated windows authentication in iis
You could try running FileMon from SysInternals to see if it is the file system that is sending back the "access denied".
Quote from another forum that solved this issue for me:
"SQL Server Reporting Services creates a folder called Reports by default if you install it on IIS. If you install SQL 2008 then Reporting Services doesn't need to use IIS and instead will try to reserve the URL with the HTTP.Sys service.
I believe this is the cause of the conflict you are seeing. What you could try is changing the URL that Reporting Services uses via the SQL Server Reporting Services Configuration Manager."
Well speaking on the same subject here, yesterday I was deploying my application on Windows Server 2008 running IIS7 w/MSSQL 2008 on there too. In my website's tree structure I had a folder named Reports that had a subfolder in it, and then the actual pages. It looked like this "Reports/SalaryReports/SalaryReport.aspx" The interesting thing was that when I clicked on a hyperlink to go to "Reports/SalaryReports/SalaryReport.aspx" I got a username/password prompt from my server. This did not happen on the VS development server when I ran the application on the development machine. So I was like hmm? I looked at the code-behind in SalaryReport.aspx and did not find anything unusual. So then I put a Default.aspx directly in the Reports folder (thinking maybe it was something wrong with the authentication going two nodes down from the root to get to SalaryReport.aspx) but the server still requested username/password even though there was no security settings applied to this new Default.aspx. So I figured it must be that the folder is named "Reports", so I renamed it to "Reports1" and bigno! Everything worked!....I will still look further in this issue today, but it seems that either an IIS 7 HttpModule (not one of mine) is trying to "reserve" the folder that is named "Reports" for itself or something else...I'll look into the SQL Server Reporting services as the above post mentioned...
Anyways, just wanted to share:)
I'm supposing you don't have a SQL Reporting Services running on the same server:
1 - Give rights to user "IUSR" and the user that's running your application pool.
2 - Overwrite child folder permissions and ownership.
2 - Check if there's a web.config file on that folder setting different access rules.

Resources