MetadataException: Unable to load the specified metadata resource

Posted by on Jun 29, 2016 in Asp.net, MVC, PowerShell

I recently came across an error in a .net application where the message was as follows: MetadataException: Unable to load the specified metadata resource 1 MetadataException: Unable to load the specified metadata resource It took a fair bit of digging but eventually found the underlying cause. My suspicions were that it was DB related due to the point in my application that it was failing. However, where/why I wasn’t sure. After a while I discovered the source of the problem. Entity Framework, in its wisdom, breaks down an EDMX into three constituent parts, a CSDL, SSDL and MSL. These are all strongly typed to the same namespace as your EDMX and thus the Entity Framework connection string will start something along the lines of: metadata=res://*/Your.Namespace.com.csdl|res://*/ Your.Namespace.com.ssdl|res://*/ Your.Namespace.com.msl; 1 metadata=res://*/Your.Namespace.com.csdl|res://*/ Your.Namespace.com.ssdl|res://*/ Your.Namespace.com.msl; Where Your.Namespace.com is obviously the namespace that corresponds to your EDMX. If these do not align, then Entity Framework will not know which embedded resource to load your EDMX from and thus you will. In my case, I was transforming the connection string using Powershell to add in some environment specific variables and mistakenly changed the resource names, hence this error. Therefore, if you run in to the problem of Unable to load the specified metadata resource, be sure to check this...

Read More »

Unable to export content from a Sharepoint list

Posted by on Feb 7, 2015 in PowerShell, SharePoint

I recently attempted to export content from a SharePoint list using PowerShell but ran into a few issues with the Export-SPWeb cmdlet. Firstly, I had a problem whereby the documented syntax of the cmdlet just didn’t work. It took a few hours playing about and guesswork to discover the syntax that played nicely with SharePoint 2013. The documented syntax is as follows: Export-SPWeb -Identity <SiteURL> -Path <Path and File Name> [-ItemUrl <URL of Site, List, or Library>] [-IncludeUserSecurity] [-IncludeVersions] [-NoFileCompression] [-GradualDelete] [-Verbose] 1 Export-SPWeb -Identity <SiteURL> -Path <Path and File Name> [-ItemUrl <URL of Site, List, or Library>] [-IncludeUserSecurity] [-IncludeVersions] [-NoFileCompression] [-GradualDelete] [-Verbose] However, attempting to transpose this to my own SharePoint site didn’t play ball. Using the following syntax, however, did in fact work: Export-SPWeb -Identity <SiteURL>\<SITE> -Path <Path and File Name> [-ItemUrl <Relative URL from SITE root>] 1 Export-SPWeb -Identity <SiteURL>\<SITE> -Path <Path and File Name> [-ItemUrl <Relative URL from SITE root>] So rather than supplying the Site URL at a collection level, I had to append the site name to the –Identity parameter and omit it from the path to the list. My next issue was permissions based, with not having adequate permissions to perform this operation. There are a plethora of permissions needed to successfully execute this command. This includes: securityadmin fixed server role on the SQL Server instance. db_owner fixed database role on all databases that are to be updated. Administrators group on the server on which you are running the Windows PowerShell cmdlets. The user is a server farm administrator. The user is a site collection administrator. With the above, and the correct syntax, things should hopefully work for...

Read More »