Why am I getting, "Error 392 Error occurred in deployment step 'Activate Features': Operation is not valid due to the current state of the object." - sharepoint-2010

Does a missing "Module" section in the Elements.xml file cause "Error 392 Error occurred in deployment step 'Activate Features': Operation is not valid due to the current state of the object."?
All of a sudden, I get that error when trying to rebuild a Sharepoint Web Part. One thing I researched indicates that perhaps Elements.xml has a problem. I haven't changed anythying in this in a long while, nor have I changed anything explicitly, I don't think, but here it is as it now stands:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Receivers ListTemplateId="104">
<Receiver>
<Name>PostTravelItemEventReceiverItemAdded</Name>
<Type>ItemAdded</Type>
<Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
<Class>PostTravelWizard.PostTravelItemEventReceiver.PostTravelItemEventReceiver</Class>
<SequenceNumber>10000</SequenceNumber>
</Receiver>
<Receiver>
<Name>PostTravelItemEventReceiverContextEvent</Name>
<Type>ContextEvent</Type>
<Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
<Class>PostTravelWizard.PostTravelItemEventReceiver.PostTravelItemEventReceiver</Class>
<SequenceNumber>10000</SequenceNumber>
</Receiver>
</Receivers>
</Elements>
So all it has right now is a reference to the two "Event Receiver" handlers I added; I compared this non-working project's Elements.xml file with other Elements.xml files I have (from Web Parts that do work); one of them looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/" >
<Module Name="TravelFormHelpWebPart" List="113" Url="_catalogs/wp">
<File Path="TravelFormHelpWebPart\TravelFormHelpWebPart.webpart" Url="TravelFormHelpWebPart.webpart" Type="GhostableInLibrary" >
<Property Name="Group" Value="Financial Affairs Forms" />
</File>
</Module>
</Elements>
...and the other one is very similar, like so:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/" >
<Module Name="DPSVisualWebPart" List="113" Url="_catalogs/wp">
<File Path="DPSVisualWebPart\DPSVisualWebPart.webpart" Url="DPSVisualWebPart.webpart" Type="GhostableInLibrary" >
<Property Name="Group" Value="Financial Affairs Forms" />
</File>
</Module>
</Elements>
The difference seems to be that the working Web Apps have a "Module" section in their Elements.xml file
There was one other clue, too, from the link above, to wit:
If step 2 didn't resolve your error, check if your deployment target is set to "WebApplication". It needs to be set to "Global AssemblyCache" instead.
...and here, too, somehow, this non-working WebPart was set to "WebApplication," whereas the others are set to "GAC"). Changing that didn't help, though - I still get the same err msg as reported above.
So if the missing "Module" section is the problem, that was apparently there earlier (when it was working) and somehow got 86'd (along with the changing of the project's "Assembly Deployment Target" property, apparently). Why would/how could that happen?

Adding (back, apparently) the Module section did the trick.
Specifically, I added the following above the "Receivers" section:
<Module Name="PostTravelWizardWebPart" List="113" Url="_catalogs/wp">
<File Path="PostTravelWizardWebPart\PostTravelWizardWebPart.webpart" Url="PostTravelWizardWebPart.webpart" Type="GhostableInLibrary" >
<Property Name="Group" Value="Financial Affairs Forms" />
</File>
</Module>
...and it now deploys successfully.
(Note that I also changed (again, back, apparently) the value of the project's "Assembly Deployment Target" property to "GlobalAssemblyCache" from "WebApplication"

Related

How can I call nuget restore recursively when using packages.config?

I have a non-.NET-based project that I'm trying to hammer nuget into for managing the dependencies. Because of that, I have to use packages.config to define the dependencies for a project.
Right now, I've got it packing and pushing exactly as I want it, but when I restore the packages, it only restores the dependencies in the packages.config I list, none of the dependencies of that package. So, for instance, if I have an application, MyApp, with a dependency on Foo, which then has a dependency on Bar, calling nuget restore on MyApp will not put Bar into the packages folder.
According to the CLI documentation, the -Recursive flag does not work for projects using packages.config - which is a problem for me, as I need to use packages.config, as far as I can tell. Or at least, I don't really want to spend another 3 hours converting all 12 of my packages to use a different format if I can help it.
For reference, here's an example of what my files look like, currently:
MyApp's package.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Foo" version="1.0.0.0" allowedVersions="[1.0]" />
</packages>
Foo.nuspec
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<!-- Required elements-->
<id>Foo</id>
<version>1.0</version>
<description>Foo</description>
<authors>Tesset</authors>
<dependencies>
<dependency id="Bar" version="[1.0]" />
</dependencies>
</metadata>
<files>
<file src=".\lib\Foo\**" target="lib\Foo" />
</files>
</package>
Bar.nuspec
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<!-- Required elements-->
<id>Bar</id>
<version>1.0</version>
<description>Bar</description>
<authors>Tesset</authors>
</metadata>
<files>
<file src=".\lib\Bar\**" target="lib\Bar" />
</files>
</package>
And, for completeness, I'm calling nuget restore like:
nuget restore ".\MyApp\packages.config" -PackageSaveMode nuspec -OutputDirectory ".\MyApp\packages" -recursive
(Having or not having the -recursive flag makes no difference to whether Bar ends up in the packages folder)
So, is there a way in nuget to make sure Bar gets restored while leaving MyApp (and Foo) using a packages.config file? If not, then is there a way to restore the dependencies listed in the nuspec file, so I can do that recursion manually on the files nuget restore puts into .\MyApp\packages?

Ghost modules in modules.xml

Here is my modules.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/../...iml" filepath="$PROJECT_DIR$/../...iml" />
<module fileurl="file://$PROJECT_DIR$/7Wonders.iml" filepath="$PROJECT_DIR$/7Wonders.iml" />
<module fileurl="file://$PROJECT_DIR$/../AFLib/AFLib.iml" filepath="$PROJECT_DIR$/../AFLib/AFLib.iml" />
<module fileurl="file://$USER_HOME$/Documents.iml" filepath="$USER_HOME$/Documents.iml" />
<module fileurl="file://$USER_HOME$/Documents.iml" filepath="$USER_HOME$/Documents.iml" />
<module fileurl="file://$USER_HOME$/Documents.iml" filepath="$USER_HOME$/Documents.iml" />
<module fileurl="file://$PROJECT_DIR$/../MultiConnect/MultiConnect.iml" filepath="$PROJECT_DIR$/../MultiConnect/MultiConnect.iml" />
<module fileurl="file://$PROJECT_DIR$/../MultiConnect/lib/MultiConnect-lib.iml" filepath="$PROJECT_DIR$/../MultiConnect/lib/MultiConnect-lib.iml" />
<module fileurl="file://$PROJECT_DIR$/_7Wonders/_7Wonders.iml" filepath="$PROJECT_DIR$/_7Wonders/_7Wonders.iml" />
<module fileurl="file://$PROJECT_DIR$/../AFLib/lib/lib.iml" filepath="$PROJECT_DIR$/../AFLib/lib/lib.iml" />
</modules>
</component>
</project>
"7 Wonders" is the app, "MultiConnect" and "AFLib" are my libraries.
The stuff starting with $USER_HOME is completely unneeded: there is no Documents.iml file. I delete these lines, Android Studio adds them back. Then it complains that it can't open a module... 2 modules... 3 modules... and so on, until I delete those lines manually again. If I click on "Details" in the error message, it offers to remove those modules from the project, but that doesn't seem to have any effect. I even tried to make the modules.xml file read-only, but Android Studio complains and refuses to work.
This issue does not affect usability, but seeing that "Error Loading Project" every single time is rather annoying.
I don't need the ...iml file (the 1st line) either, but at least the Studio doesn't complain about it, and doesn't add several copies of it.
Can anyone explain what's going on?
There could be many reasons why this is happening.
1. Uninstall plugin "Markdown support" from plugins in settings.
Try compiling the whole project before gradle refresh is done. And set gradle settings as "Offline Work".
This will save a lot of time and will also save on re-installation of gradle dependencies. This re-install probably will cause refresh in modules.xml

MSBuild Web Deploy not updating connection strings

I am currently trying to get my deployment process up and running on my production server. Currently I am using the web deploy and publish profiles to achieve this, and I have everything working correctly, apart from the updating of connection strings to suit the production server.
I am using:
msbuild myProj.csproj /p:DeployOnBuild=true;PublishProfile=myProfile;Configuration=Release
to create the publish package, and the:
call myProj.deploy.cmd /Y /M:http://myServer/MSDeployAgentService -allowUntrusted /U:user /:Password
So this is working, it packages and then sends it to the server fine, and configures IIS correctly, but points to the wrong database.
My publishing profile looks like:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<SiteUrlToLaunchAfterPublish />
<MSDeployServiceURL>http://myserver</MSDeployServiceURL>
<DeployIisAppPath>Website</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>RemoteAgent</MSDeployPublishMethod>
<UserName>user</UserName>
<_SavePWD>True</_SavePWD>
<PublishDatabaseSettings>
<Objects xmlns="">
<ObjectGroup Name="DBContext" Order="1" Enabled="False">
<Destination Path="Data Source=server;Initial Catalog=ProductionDB;User ID=user;Password="password"" Name="" />
<Object Type="DbCodeFirst">
<Source Path="DBMigration" DbContext="myproj.Repositories.DBContext, myproj.Repositories" MigrationConfiguration="myproj.Repositories.Migrations.Configuration, myproj.Repositories" Origin="Configuration" />
</Object>
</ObjectGroup>
<ObjectGroup Name="DefaultConnection" Order="2" Enabled="False">
<Destination Path="Data Source=server;Initial Catalog=ProductionDB;User ID=user;Password="password"" Name="" />
<Object Type="DbDacFx">
<PreSource Path="Data Source=localhost;Initial Catalog=devDB;User ID=user;Password="password"" includeData="False" />
<Source Path="$(IntermediateOutputPath)AutoScripts\DefaultConnection_IncrementalSchemaOnly.dacpac" dacpacAction="Deploy" />
</Object>
<UpdateFrom Type="Web.Config">
<Source MatchValue="Data Source=localhost;Initial Catalog=devDB;User Id=user;Password=password" MatchAttributes="$(UpdateFromConnectionStringAttributes)" />
</UpdateFrom>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
</PropertyGroup>
<ItemGroup>
<MSDeployParameterValue Include="$(DeployParameterPrefix)DBContext-Web.config Connection String">
<ParameterValue> Data Source=server;Initial Catalog=ProductionDB;User ID=user;Password="password"</ParameterValue>
</MSDeployParameterValue>
<MSDeployParameterValue Include="$(DeployParameterPrefix)DefaultConnection-Web.config Connection String">
<ParameterValue>Data Source=server;Initial Catalog=ProductionDB;User ID=user;Password="password"</ParameterValue>
</MSDeployParameterValue>
</ItemGroup>
</Project>
Annoyingly this works fine when Publishing directly from VS2012, just not via command line. Is there a switch or option I am missing from my msbuild call maybe?
It is not working correctly as in my myProj.SetParameters.xml file, the connection strings shown in there are wrong. If I manually change these to the correct connection strings, then the web.xml file is correct on the production server once deployed. How do I get the correct string into my SetParameters file? Any help would be greatly appreciated.
In the end to get around this, in Visual Studio I created a Parameters.xml file in the root of project which holds the values of the connection strings to be used on the production server. These are picked up and used instead of the default values.
The Parameters.xml file looks like:
<?xml version="1.0" encoding="utf-8" ?>
<parameters>
<parameter name="DefaultConnection-Web.config Connection String"
description=""
defaultValue=""tags="" />
Just add as many as you require and obviously populate the attributes as required
My DefaultConnection was not updating either. It turned out that I had to delete the MyProject > PublishProfiles .pubxml file.
Then when attempting to publish the newly built project it asked me to connect to azure and download the publishing profile.
Even though that wizard has a checkbox with the option to turn off overriding the DefaultConnection string with the one pulled down with the publishing profile, unchecking it had no effect. It continued to overwrite the string.
So in the azure control panel (portal) I clicked Websites > My Website > Configure
Scroll down to connection strings and you can show the hidden connection string. I just removed it by hitting the x and then hardcoded the correct one in my web config.
I then removed the .pubxml again and went through the wizard again. Now there is not connectionstring being pulled down with the publish profile.
My Publish Profile .pubxml file (found in Project\Properties\PublishProfiles) had become corrupt with extra duplicate "DefaultConnection-Web.config Connection String" nodes. The connection string updated correctly after I deleted the extra nodes.

Windows 8 App Manifest: Image Assets Error

These images default VS images.But it doesn't work.
Error 4 Payload file
'C:\Users\Mert\documents\visual studio 2012\Projects\Y\P\Assets\StoreLogo.scale-100.png' does not exist.
Error 3 Payload file
'C:\Users\Mert\documents\visual studio 2012\Projects\Y\P\Assets\SplashScreen.scale-100.png' does not exist.
Error 2 Payload file
'C:\Users\Mert\documents\visual studio 2012\Projects\Y\P\Assets\SmallLogo.targetsize-32.png' does not exist.
Error 1 Payload file
'C:\Users\Mert\documents\visual studio 2012\Projects\Y\P\Assets\SmallLogo.scale-100.png' does not exist.
I know question is incomprehensible but I don't find different way to explain.
Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
<Identity Name="" Publisher="CN=Mert" Version="1.0.0.0" />
<Properties>
<DisplayName>Y</DisplayName>
<PublisherDisplayName>Mert</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.2.1</OSMinVersion>
<OSMaxVersionTested>6.2.1</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="Y.App">
<VisualElements DisplayName="Y" Logo="Assets\Logo.png" SmallLogo="Assets\SmallLogo.png" Description="Y" ForegroundText="light" BackgroundColor="#464646">
<DefaultTile ShowName="allLogos" />
<SplashScreen Image="Assets\SplashScreen.png" />
</VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
</Package>
I also had this problem last day. I noticed that when I deleted an image from assert, it wont delete its occurrence from the Solution explorer in Visual Studio. Delete those files from solution explorer fixed the issue.
Cheers...!
I just encountered this myself.
It seems Visual Studio can't handle a trial-and-error approach for logos.
I got rid of it by manually editing the .csproj file and removing the missing assets from there.
There is a workaround by setting the Generate App Bundle setting to Never.

Deployed Sharepoint 2010 WebPart, but where is it?

Followed the steps in the answer to this question: How to deploy custom webpart from one server to another in sharepoint 2010
It all seemed to work ok, but now what do I do? If I 'edit' the home page of the sharepoint site and click "Add Web PArt", I don't see it in the list.
I am a complete newbie when it comes to Sharepoint, so simple steps would be appreciated.
Cheers.
The Web Part definition files have to be in the Web Part Gallery in order to be available in the "Add Web Part List".
You can create a SharePoint site feature to deploy the definition files in this library:
feature.xml:
<?xml version="1.0" encoding="utf-8" ?>
<Feature
xmlns="http://schemas.microsoft.com/sharepoint/"
Id="DFD20610-C329-45E0-B037-8E6FC0A684AB"
Title="Web Part Feature"
Scope="Site"
>
<ElementManifests>
<ElementManifest Location="Elements.xml" />
<ElementFile Location="TheWebPart.dwp" />
</ElementManifests>
</Feature>
Elements.xml:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="WebPartPopulation" Url="_catalogs/wp" RootWebOnly="TRUE">
<File Path="TheWebPart.dwp" Url="TheWebPart.dwp" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE">
<Property Name="Group" Value="Custom" />
</File>
</Module>
</Elements>
I think the Module line within Elements.xml also needs to contain List="113"