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

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>

Related

Updating Azure App Service web.config to load .ttf font files

Wracking my brain but can't seem to find the solution. I have a .ttf font file, located on Azure storage blob, being used for a custom font on my Azure App Service site. I get a 404 "resource not found" error for this file.
After reading a ton of documentation on this, it seems I need to add a couple of lines of code, for a new "mimetype", to the web.config file. Older versions of Azure had this in "Extensions" or "Application Settings".
Other people show the ability to do so in Kudu under the "Debug" option. However, I can't seem to find either of those - "Configuration" shows environment variables and I don't see a "Debub" option in my Kudu portal.
Kudu Console without "Debug" option
How do I actually update the web.config file or at the very least be able to load a .ttf file???
Go to Kudu, then go to wwwroot folder and edit web.config file with the following, or just create one in case it's not there:
PS: previous image shows LogFiles folder, but it should be wwwwroot
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".ttf" />
<mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
</configuration>

XML transformation not working

I have installed the SlowCheetah extension and Nuget Package into my Console App Project. I have used the context menu to add a UAT build configuration and updated a test setting to check that the value is being transformed.
Unfortunately its not, when I try to Preview the Transform via the Context Menu its just showing me the non transformed App.Config.
What steps can I check to see why this extension is not working?
In the main App Config I have specified an appSetting.
<appSettings>
<add key="TomTestTransform" value="LOCAL" />
</appSettings>
In the App.UAT.config I overwrite it
<appSettings>
<add key="TomTestTransform" value="UAT" />
</appSettings>
When I preview the Transform, or build and check the configuration output, its always using the non transformed version. The setting equals LOCAL.
You need to use xdt: attributes to match and adapt the elements, like so:
<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations
see the web.comfig examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="TomTestTransform"
value="UAT"
xdt:Transform="Replace"
xdt:Locator="Match(key)" />
</appSettings>
</configuration>
With xdt:Locator="Match(key)" you are telling the processor to match the add element based on the key attribute, and apply xdt:Transform="Replace" logic on the whole (located) element.
There is a msdn entry available on possible XML transformations, which is also applicable for SlowCheetah transformations, as they are based on the same "technology".
Additionally, the extension overview has also some good documentation in it!

Can't get SVG served from Azure

I'm building a static HTML5 web site on VS2014 and deploying via Dropbox to be hosted on Azure. All works using F5 on VS2014. But my SVG images do not get served from Azure. I get HTTP/1.1 404 Not Found errors. I have tried this solution:
Use SVG in Windows Azure Websites and the code snippet suggested by Mads Kristensen at http://madskristensen.net/post/prepare-webconfig-for-html5-and-css3. My web.Debug.config & web.Release.config files are both as follows:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<staticContent>
<remove fileExtension=".svg"/>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>
</configuration>
Here's the question. What should I do to get my svg files to download?
EDIT: I found the problem. As a relative new user of VS2014 and Azure, I overlooked the higher level Web.config file and only worked with the lower two files mentioned above. Putting the additional staticContent lines into the Web.config file fixed everything.
I found the problem. As a relative new user of VS2014 and Azure, I overlooked the higher level Web.config file and only worked with the lower two files mentioned above. Putting the additional staticContent lines into the Web.config file fixed everything.

Sharepoint webpart deployment - activate features error

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.

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