{"id":7212,"date":"2014-08-06T17:59:50","date_gmt":"2014-08-06T17:59:50","guid":{"rendered":"https:\/\/test.simple-talk.com\/uncategorized\/fixing-nativehr-0x80070002-error-when-retracting-or-deploying-sharepoint-apps-from-visual-studio\/"},"modified":"2016-07-28T10:55:26","modified_gmt":"2016-07-28T10:55:26","slug":"fixing-nativehr-0x80070002-error-when-retracting-or-deploying-sharepoint-apps-from-visual-studio","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/blogs\/fixing-nativehr-0x80070002-error-when-retracting-or-deploying-sharepoint-apps-from-visual-studio\/","title":{"rendered":"Fixing NativeHR 0x80070002 Error When Retracting or Deploying SharePoint Apps from Visual Studio"},"content":{"rendered":"<p>Sometimes when App deployment fails from Visual Studio you will get the following error when trying to retract or redeploy the app:<\/p>\n<p>&lt;nativehr&gt;0x80070002&lt;\/nativehr&gt;&lt;nativestack&gt;&lt;\/nativestack&gt;<\/p>\n<p>There seems to be some issue with the information in the content database.&#160; To fix the problem I just deleted all of the information from the App tables in the content database.&#160; We only have one app in testing at a time so this worked fine for me.&#160; Doing this in a production environment or if you have multiple apps installed is <strong>not recommended<\/strong>, so if you are in either of those scenarios you will probably have to dig into those tables to find the offending entries.&#160; You may also have to remove some of the App principal entries from the App Service Application database as well (I&#8217;ll try to update this post if we find that to be true).&#160;&#160; I&#8217;m going to post the SQL to do the full deletion, but be careful when running this:<\/p>\n<p><strong>DO NOT RUN THIS IN A PRODUCTION ENVIRONMENT:<\/strong><\/p>\n<p>DELETE FROM [dbo].[AppDatabaseMetadata]   <br \/>DELETE FROM [dbo].[AppInstallationProperty]    <br \/>DELETE FROM [dbo].[AppInstallations]    <br \/>DELETE FROM [dbo].[AppJobs]    <br \/>DELETE FROM [dbo].[AppLifecycleErrors]    <br \/>DELETE FROM [dbo].[AppPackages]    <br \/>DELETE FROM [dbo].[AppPrincipalPerms]    <br \/>DELETE FROM [dbo].[AppPrincipals]    <br \/>DELETE FROM [dbo].[AppResources]    <br \/>DELETE FROM [dbo].[AppRuntimeIcons]    <br \/>DELETE FROM [dbo].[AppRuntimeMetadata]    <br \/>DELETE FROM [dbo].[AppRuntimeSubstitutionDictionary]    <br \/>DELETE FROM [dbo].[AppSourceInfo]    <br \/>DELETE FROM [dbo].[AppSubscriptionCosts]    <br \/>DELETE FROM [dbo].[AppTaskDependencies]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes when App deployment fails from Visual Studio you will get the following error when trying to retract or redeploy the app: &lt;nativehr&gt;0x80070002&lt;\/nativehr&gt;&lt;nativestack&gt;&lt;\/nativestack&gt; There seems to be some issue with the information in the content database.&#160; To fix the problem I just deleted all of the information from the App tables in the content database.&#160;&#8230;&hellip;<\/p>\n","protected":false},"author":46738,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[],"coauthors":[],"class_list":["post-7212","post","type-post","status-publish","format-standard","hentry","category-blogs"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/7212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/46738"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=7212"}],"version-history":[{"count":3,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/7212\/revisions"}],"predecessor-version":[{"id":42406,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/7212\/revisions\/42406"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=7212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=7212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=7212"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=7212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}