Sharepoint webpart deployment - activate features error - sharepoint

I'm a noob to Sharepoint development, actually I hoped I'd always be a noob to it, and I'm having difficulty building my first web part for a Sharepoint 2010 website. I'm using Visual Studio 2010, and I started with a Visual Web Part. All i added was a simple asp:Label control, as I just want to make sure it's deploying correctly before I go any further. It builds, says it's deploys even, and then croaks on the 'activate feature' step. I get the following error.
Error 1 Error occurred in deployment step 'Activate Features': Feature with Id '12765e82-6e4a-4407-aa8c-77b537841f4b' is not installed in this farm, and cannot be added to this scope. 0 0 scCodePart
There isn't much out there to go by for help on this. I made sure the scope of the feature was set to 'Site', as was recommended. I even tried changing the xml of Feature1.Template.xml to:
<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="12765e82-6e4a-4407-aa8c-77b537841f4b" Scope="Site" xmlns="http://schemas.microsoft.com/sharepoint/">
</Feature>
And the error persists. I read something about the web.config of the site might causing it, but it provided no explanation as to why. Any thoughts?
EDIT
There is my Elements.xml:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/" >
<Module Name="scClosetCodesVWP" List="113" Url="_catalogs/wp">
<File Path="scClosetCodesVWP\scClosetCodesVWP.webpart" Url="scClosetCodesVWP.webpart" Type="GhostableInLibrary" >
<Property Name="Group" Value="Custom" />
</File>
</Module>
</Elements>
and my Feature1.Template.xml:
<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/">
</Feature>
I haven't altered either one of them from what Visual Studio initially creates. I tried declaring the id & scope in Feature1.Template.xml, but i got the same error after.

kindly go through the following URL which has complete solution for your problem
http://blogs.msdn.com/b/sowmyancs/archive/2008/04/02/server-error-feature-guid-is-not-installed-in-this-farm-and-cannot-be-added-to-this-scope.aspx

It sounds like you have the incorrect scope set for your feature. Take a look here to see what features can be deployed at what scope.
Simplest way is just to weak that scope setting, redeploy and see if you get a better result :)

if you have farm admin privilages, you can goto the Central Admin -> System Settings -> Manage Farm Solutions
Select Project.wsp file and click on Deploy Solution
Depending the feature scope setting, go there to activate it.
For Example, if its site collection level, goto site collection settings and activate it.
Alternately you can also use powershell to do the same thing.

Related

Is it possible to change web.config values based on the hosting environment, such as iisExpress

I am developing a .net core 3.0 web app with a very simple web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<serverRuntime uploadReadAheadSize="10485760" />
</system.webServer>
</configuration>
However, I want to change the web.config file so that this configuration is active with iis, but not with iisExpress, where the permissions to change uploadReadAheadSize are locked.
Surely there must be a simple way to do this, but all my googling hasn't given me a straightforward answer
Due to the design, there seems to be no way to tell from within web.config whether the hosting server is IIS or IIS Express.
But because IIS and IIS Express use different configuration file path, you can move such configuration elements from your web.config file to the desired applicationHost.config file.

Replaced an image in Visual Studio, "Cannot be found" when deployed

I replaced an image in a SharePoint project in Visual Studio. When I deploy the image cannot be found. I can see it in SharePoint designer, but when I try the url it just gives me an error ("Cannot be found"). It doesn't give me any error message when deploying.
The image is located in a module ("Images").
The only thing that's changed in the picture is the size, it still has the same name and file type.
Why is it behaving like this?
Images/Elements.xml:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="Images">
<File Path="Images\customLogo.jpg" Url="Images/customLogo.jpg" />
</Module>
</Elements>

Config Error: This configuration section cannot be used at this path

I've encountered an error deploying a site to a server. When trying to load the home page, or access authentication on the new site in IIS, I get the error:
Config Error: This configuration section cannot be used at this path.
This happens when the section is locked at a parent level. Locking is
either by default (overrideModeDefault="Deny"), or set explicitly by a
location tag with overrideMode="Deny" or the legacy
allowOverride="false".
More detail can be found here, in Scenario 7 matches my hex error code.
The solution given on the linked site above is to set Allow for overrideModeDefault in the section mentioned in my error, in the applicationHost.config file. In my case, under Security in system.webServer. But if I look at the applicationHost.config on my local computer, where the site is properly deployed already, that section is set to Deny.
If this solution is correct, how is my local instance running just fine with the same web.config? According to my applicationHost.config, that section should be locked, but it's not. I'd prefer to not change the applicationHost.config file, because there are many other sites running on that server. Is there another solution?
I had the same problem. Don't remember where I found it on the web, but here is what I did:
Click "Start button"
in the search box, enter "Turn windows features on or off"
in the features window, Click: "Internet Information Services"
Click: "World Wide Web Services"
Click: "Application Development Features"
Check (enable) the features. I checked all but CGI.
btw, I'm using Windows 7. Many comments over the years have certified this works all the way up to Windows 10 and Server 2019, as well.
You could also use the IIS Manager to edit those settings.
Care of this Learn IIS article:
Using the Feature Delegation from the root of IIS:
You can then control each of machine-level read/write permissions, which will otherwise give you the overrideMode="Deny" errors.
For Windows Server 2012 and IIS 8, the procedure is similar.
The Web Server (IIS) and Application Server should be installed, and you should also have the optional Web Server (IIS) Support under Application Server.
Browse to “C:\Windows\System32\inetsrv\config” (you will need administrator rights here)
Open applicationHost.config
Note: In IISExpress and Visual Studio 2015 the applicationHost.config is stored in $(solutionDir).vs\config\applicationhost.config
Find the section that showed up in the “config source” part of the error message page. For me this has typically been “modules” or “handlers”
Change the overrideModeDefault attribute to be Allow
So the whole line now looks like:
<section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Allow" />
After saving the file, the page loaded up fine in my browser.
Warning:
Editing applicationHost.config on 64-bit Windows
You need to unlock handlers. This can be done using following cmd command:
%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/handlers
Maybe another info for people that are getting this error on IIS 8, in my case was on Microsoft Server 2012 platform. I had spend couple of hours battling with other errors that bubbled up after executing appcmd. In the end I was able to fix it by removing Web Server Role and installing it again.
1. Open "Turn windows features on or off" by: WinKey+ R => "optionalfeatures" => OK
Enable those features under "Application Development Features"
Tested on Win 10 - But probably will work on other windows versions as well.
I ran these two commands from an elevated command prompt:
%windir%/system32/inetsrv/appcmd unlock config /section:anonymousAuthentication
%windir%/system32/inetsrv/appcmd unlock config /section:windowsAuthentication
As per my answer to this similar issue;
Try unlocking the relevant IIS configuration settings at server level, as follows:
Open IIS Manager
Select the server in the Connections pane
Open Configuration Editor in the main pane
In the Sections drop down, select the section to unlock, e.g. system.webServer > defaultPath
Click Unlock Attribute in the right pane
Repeat for any other settings which you need to unlock
Restart IIS (optional) - Select the server in the Conncetions pane, click Restart in the Actions pane
This Did the trick for me, for IIS 8 Windows server 2012 R2
Go to "Turn on Features"
Then go to all default setting , Next, Next, Next etc..
Then, select as shown below,
Then reset IIS (optional) but do it safer side.
This is an additional solution as its a generic problem everyone have different of problem and thus different solution. Cheers!
The best option is to Change Application Settings from the Custom Site Delegation
Open IIS and from the root select Feature Delegation and then select Application Settings and from the right sidebar select Read/Write
On Windows Server 2012 with IIS 8 I have solved this by enabling ASP.NET 4.5 feature:
and then following ken's answer.
To fix this open up the IIS Express applicationhost.config. This file is stored at C:\Users[your user name]\Documents\IISExpress\config\applicationhost.config
Update for VS2015+: config file location is $(solutionDir).vs\config\applicationhost.config
Look for the following lines
<section name="windowsAuthentication" overrideModeDefault="Deny" />
<section name="anonymousAuthentication" overrideModeDefault="Deny" />
<add name="WindowsAuthenticationModule" lockItem="true" />
<add name="AnonymousAuthenticationModule" lockItem="true" />
Change those lines to
<section name="windowsAuthentication" overrideModeDefault="Allow" />
<section name="anonymousAuthentication" overrideModeDefault="Allow" />
<add name="WindowsAuthenticationModule" lockItem="false" />
<add name="AnonymousAuthenticationModule" lockItem="false" />
Save it and refresh Asp.net Page.
In our case on IIS 8 we found the error was produced when attempting to view Authentication" for a site, when:
The server Feature Delegation marked as "Authentication - Windows" = "Read Only"
The site had a web.config that explicitly referenced windows authentication; e.g.,
Marking the site Feature Delegation "Authentication - Windows" = "Read/Write", the error went away. It appears that, with the feature marked "Read Only", the web.config is not allowed to reference it at all even to disable it, as this apparently constitutes a write.
Seems that with IIS Express and VS 2015, there's a copy of the applicationHost.config file at $(solutionDir).vs\config\applicationhost.config so you'll need to make changes there. See this link: http://digitaldrummerj.me/iis-express-windows-authentication/
Make sure these lines are changed per below:
<section name="windowsAuthentication" overrideModeDefault="Allow" />
<section name="anonymousAuthentication" overrideModeDefault="Allow" />
<add name="WindowsAuthenticationModule" lockItem="false" />
<add name="AnonymousAuthenticationModule" lockItem="false" />
In my case it was that on server was not enabled "HTTP Activation" under .NET Framework Features. So for Windows Server 2012 the solution which worked for me was:
Server Manager -> Add roles and features -> Features -> make sure that under .NET Framework of version you want to use is checked "HTTP Activation"
The Powershell way of enabling the features (Windows Server 2012 +) - trim as needed:
Install-WindowsFeature NET-Framework-Core
Install-WindowsFeature Web-Server -IncludeAllSubFeature
Install-WindowsFeature NET-Framework-Features -IncludeAllSubFeature
Install-WindowsFeature NET-Framework-45-ASPNET -IncludeAllSubFeature
Install-WindowsFeature Application-Server -IncludeAllSubFeature
Install-WindowsFeature MSMQ -IncludeAllSubFeature
Install-WindowsFeature WAS -IncludeAllSubFeature
The error says that the configuration section is locked at the parent level.
So it will not be directly 1 config file which will resolve the issue,
we need to go through the hierarchy of the config files to see the inheritance
Check the below link to go through the File hierarchy and inheritance in IIS
https://msdn.microsoft.com/en-us/library/ms178685.aspx
So you need to check for the app config settings in the below order
ApplicationHost.config in C:windows\system32\inetsrv\config. Change the overrideModeDefault attribute to be Allow.
ApplicationName.config or web.config in the applications directory
Web.config in the root directory.
Web.config in the specific website (My issue was found at this place).
Web.config of the root web (server's configuration)
machine.config of the machine (Root's web.config and machine.config can be found at - systemroot\MicrosoftNET\Framework\versionNumber\CONFIG\Machine.config)
Go carefully through all these configs in the order of 1 to 6 and you should find it.
I noticed one answer that was similar, but in my case I used the IIS Configured Editor to find the section I wanted to "unlock".
Then I copied the path and used it in my automation to unlock it prior to changing the sections I wanted to edit.
. "$($env:windir)\system32\inetsrv\appcmd" unlock config -section:system.webServer/security/authentication/windowsAuthentication
. "$($env:windir)\system32\inetsrv\appcmd" unlock config -section:system.webServer/security/authentication/anonymousAuthentication
I needed to change the SSL settings on a subfolder when i got this nice message. In my case following action helped me out.
Opened C:\Windows\System32\inetsrv\config\applicationHost.config
And changed the value from overrideModeDefault="Deny" to "Allow"
<sectionGroup name="system.webServer">
...
<sectionGroup name="security">
<section name="access" overrideModeDefault="Allow" />
</sectionGroup>
In my case, I got this error because I was operating on the wrong configuration file.
I was doing this:
Configuration config = serverManager.GetWebConfiguration(websiteName);
ConfigurationSection serverRuntimeSection = config.GetSection("system.webServer/serverRuntime");
serverRuntimeSection["alternateHostName"] = hostname;
instead of the correct code:
Configuration config = serverManager.GetApplicationHostConfiguration();
ConfigurationSection serverRuntimeSection = configApp.GetSection("system.webServer/serverRuntime", websiteName);
serverRuntimeSection["alternateHostName"] = hostname;
in other words, I was trying to operate on the website's web.config instead of the global file C:\Windows\System32\inetsrv\config\applicationHost.config, which has a section (or can have a section) for the website. The setting I was trying to change exists only in the applicationHost.config file.
In my case, it was something else.
When I loaded the solution in a new version of Visual Studio, VS apparently created a new project-specific applicationhost.config file:
MySolutionDir\.vs\config\applicationhost.config
It started using the settings from the new config, instead of my already customized global IIS Express settings.
(\Users\%USER%\Documents\IISExpress\config\applicationhost.config)
In my case this was the setting that needed to be set. Of course it could be something else for you:
<section name="ipSecurity" overrideModeDefault="Allow" />
Received this same issue after installing IIS 7 on Vista Home Premium. To correct error I changed the following values located in the applicationHost.config file located in Windows\system32\inetsrv.
Change all of the following values located in section -->
<div mce_keep="true"><section name="handlers" overrideModeDefault="Deny" /> change this value from "Deny" to "Allow"</div>
<div mce_keep="true"><section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Deny" /> change this value from "Deny" to "Allow"</div>
Can You try this:
Go to application path where you're getting deny error, right click
Properties->Security tab
In that, change the permissions and check the checkbox read and write. Then it will work without any error hopefully.
For Windows Server 2008 and IIS 7, the procedure is similar.
please refer to this:
http://msdn.microsoft.com/en-us/library/vstudio/bb763178(v=vs.100).aspx
in add role service, u will see "Application Development Features"
Check (enable) the features. I checked all.
In my case I was getting this error when attempting to update the authentication settings in IIS also in addition to browsing. I was able to remove this error by removing the authentication setting from the web.config itself. Removing a problematic configuration section may be less invasive and preferable in some cases than changing the server roles and features too much:
Section Removed:
<security>
<authentication>
<windowsAuthentication enabled="true" />
</authentication>
</security>
I had the similar issue, but I used the following powershell script which helped me to achieve above steps in on button click.
#Install IIS
Import-Module ServerManager
Add-WindowsFeature Web-Server, Web-Asp-Net45, Web-Mgmt-Console, Web-Scripting-Tools, NET-WCF-HTTP-Activation45, Web-Windows-Auth
the list of features can be added or removed based on the requirement.
I had an issue where I was putting in the override = "Allow" values (mentioned here already)......but on a x64 bit system.......my 32 notepad++ was phantom saving them. Switching to Notepad (which is a 64bit application on a x64 bit O/S) allowed me to save the settings.
See :
http://dpotter.net/technical/2009/11/editing-applicationhostconfig-on-64-bit-windows/
The relevant text:
One of the problems I’m running down required that I view and possibly edit applicationHost.config. This file is located at %SystemRoot%\System32\inetsrv\config. Seems simple enough. I was able to find it from the command line easily, but when I went to load it in my favorite editor (Notepad++) I got a file not found error. Turns out that the System32 folder is redirected for 32-bit applications to SysWOW64. There appears to be no way to view the System32 folder using a 32-bit app. Go figure.
Fortunately, 64-bit versions of Windows ship with a 64-bit version of Notepad. As much as I dislike it, at least it works.
I had the same issue.
Resolved it by enabling Application Server feature. Restarted iis
after that.
This worked for me
Also in IIS 8 you can solve this problem by changing the server to IIS Express. Goto debug->Properties
In the Web select the server as IIS Express from the dropdown and then rebuild the solution
To make a change at Application Level (Web.Config):
Please remove the Trust Level from the web.config:
Actually I was getting this error when I was trying to host my Website on the Hosting Server where I don't have control on their Server. Removing the above line from my Application web.config solved my issue.

VC++ 6.0 App must run as Admin to access a DB in the Common Application Data area

I have an old C++/MFC app written with VS 6. I am trying to make it compliant with Windows Vista and 7 by moving the DB directory to the Common Application Data area. But when I try to open the Access DB using DAO it reads the primary table, finds no records, and reports that no data is found. However, if I select "Run as Admin", then I can access it without an issue.
Should I be storing the database in another location? If not, why does it fail to read the table correctly?
Also, I have tried using the manifest listed below, that I found online, but it does not seem to force the application to run as admin and so I still get the no data found message. But I don't know much about manifests yet, so it could be that I didn't configure it correctly.
Thanks for any help or advise you can give.
FieldAppl
Here is the manifest I used to ensure my custom-written installer ran as an administrator. In addition to this manifest, I also digitally signed the application with a Verisign certificate.
Scott
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0"
processorArchitecture="X86"
name="Setup"
type="win32"/>
<description>Software Installation</description>
<!-- Identify the application security requirements. -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="requireAdministrator"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly
>

Sharepoint web part: type could not be found/registered as safe

I have a SharePoint web part (essentially just a "Hello World" app) that I just created and am having a problem deploying it. I have signed the .dll, created the .dwp, and registered it as a safe control in web.config. I am able to add it to the Web Part Gallery and add the details for it; however, when I attempt to add it to a page, I get the following error:
A Web Part or Web Form Control on this
Page cannot be displayed or imported.
The type could not be found or it is
not registered as safe.
Following is my .dwp file:
<?xml version="1.0"?>
<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
<Assembly>SimpleWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=################</Assembly>
<TypeName>MyWebParts.SimpleWebPart</TypeName>
<Title>My Simple Web Part</Title>
<Description>A simple Web Part</Description>
</WebPart>
and the entry I added to web.config:
<SafeControl Assembly="SimpleWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=################" Namespace="MyWebParts" TypeName="*" Safe="True" />
I also tried using wildcards for the namespace, which didn't help. I have even tried setting the web.config trust level to "Full" (which I would never do in production, but tried to attempt to narrow down the problem) and still had no luck. Any ideas? Thanks.
One possibility is that types names are not in sync with the .webpart file. For ex.
In the .webpart file:
<?xml version="1.0" encoding="utf-8"?>
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Namespace.Class1, $SharePoint.Project.AssemblyFullName$" />
and in the .cs file:
namespace Namespace
{
public class Class2 : WebPart
and in the SharePointProjectItem.spdata file:
<SafeControl Assembly="Class2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9385058ce1ee51a9" Namespace="Namespace" TypeName="*" Safe="True" SafeAgainstScript="False" />
you get the idea: triple-check names consistency across all project artifacts.
Are you deploying your webpart using a SharePoint Solution (.wsp file)? Check out WSPBuilder if you aren't. We also use SharePoint Installer Between the two, a lot of the problems (whether stemming from human error or otherwise) in deployments, like your problem have been resolved in our environment.
Make sure that you have the Web Part class as Public, might sound silly but I faced once. Also try to populate the web part from the Web part Gallery .
I also saw this problem when I changed the namespace for my WebPart assembly, and the namespace wasn't updated in all of the source files in the solution.
Did you try deploying it to the GAC?
Ok , this may be very late but will be useful for the rest. I created a webpart and was getting the error "A Web Part or Web Form Control on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe."
I figured that I was using a Chart inside this webpart and once I removed the reference of the chart, it worked. So, the Chart control has to be also marked as typesafe.
Make sure all the references in the webpart are type safe.
This usually happens when you change the name of the web part from VisualWebPart1 to MyNewWebPart. After doing a Search and Replace over the entire solution, rename all of the files and folders with VisualWebPart1 to MyNewWebPart. The problem is caused by the file SharePointProjectItem.spdata not being updated. Open SharePointProjectItem.spdata and replace VisualWebPart1 with MyNewWebPart. This fixes the problem in most cases.
Open every file in the solution and verify that there are no references to VisualWebPart1. If there are, change them manually to MyNewWebPart.
Geo,
It's been a while since I worked with Web Parts but I laid out the steps here:
http://www.codersbarn.com/?tag=/webpart
Maybe there's something there that can help.
Anthony :-)
As Tim Scarborough already mentioned, this can happen if you change the namespace and don´t update all source files (as this is not done automatically). Just for illustration, in my case the problem was that the webpart class had a new namespace a.b but I forgot to update this in the webpart file:
<?xml version="1.0" encoding="utf-8"?>
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
//update below!
<type name="a.b.yourClass, $SharePoint.Project.AssemblyFullName$" />
<importErrorMessage>$Resources:core,ImportErrorMessage;</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title" type="string">your Title</property>
<property name="Description" type="string">your Description</property>
</properties>
</data>
</webPart>
</webParts>
Well, if you have already found the solution, that's great. But here is a tip for someone who is searching for more. If you added a new webpart or a visual webpart and just replace the namespace in the files such as code files or Element.xml or even .webpart file you might still face this issue. The reason is, as mentioned somewhere above, the namespace was not changed in .spdata file, which is a file created by Visual studio itself. Just to be sure go check in the Virtual Directories in the inetroot. If the namespace is still the older one, do a search in your Solution and find out the conflicting one. Most probably in the project.spdata file, which everyone tends to ignore.

Resources