This project is read-only.

Modifying the code and redeploying the solution

Jun 5, 2008 at 5:34 PM
I was wondering if there were instructions on how to redeploy the solution for testing after making a change to the source code.

Thanks,
Vaegy
Jun 12, 2008 at 3:54 PM


Vaegy wrote:
I was wondering if there were instructions on how to redeploy the solution for testing after making a change to the source code.

Thanks,
Vaegy


You will need to create a new strong name for the assembly by using the sn utility (sn -k keyname within the project directory).  You will then need to sign the assembly with the key that you have created and update your web.config (SafeControls/SafeControl section) for the Web Application, Feature.xml and the .webpart files to reflect the new PublicKeyToken value.  From that point, you can make whatever changes you want to the source code, rebuild it and drop the assembly in the \bin folder of your web application root.  Be sure to remove the Post-Build events that may/may not exist in the source version, of course.

If you require any more assistance please let me know.
Jun 12, 2008 at 6:26 PM
Edited Jun 12, 2008 at 10:06 PM
Thanks for your reply. I still have a problem in successfully deploying the solution. Here is what I did:

I used Visual Studio to sign the assembly using a strong name for the key file. I then deleted the post-build events in Visual Studio. I rebuilt the solution and used reflector to extract the value for the public key token for the assembly. I then updated Feature.xml, SearchBreadCrumbs.webpart and SearchFacets.webpart to reflect the new token by editing the public token in the line that has the name, version, culture and publickeytoken. I rebuild the solution. I then dropped the assembly into the bin directory of my application C:\Inetpub\wwwroot\wss\VirtualDirectories\80\bin. Next I edited the web.config file located in C:\Inetpub\wwwroot\wss\VirtualDirectories\80 and added and entry for the extended search dll into the safe controls section (with its new public key token).

I still get an error saying: Exception Details: System.Security.Policy.PolicyException: Required permissions cannot be acquired.

The only thing I did differently was using Visual Studio instead of the sn utility. Though I don't think that should make a difference. Not sure what else to do - what am I missing?

Thanks,
Vaegy
Jun 13, 2008 at 4:46 AM
Try to set Trust to Full in web.config and see if the error goes away. If that's the case, you have a problem with related to the custom CAS policy used by Faceted Search.

Vaegy wrote:
I was wondering if there were instructions on how to redeploy the solution for testing after making a change to the source code.

Thanks,
Vaegy


Jun 17, 2008 at 6:48 PM
Edited Jun 18, 2008 at 5:37 PM
I changed the trust level to "Full" and now I can pull up the pages on the website including the search page. So the error I was getting earlier seems to have gone away - at least I can get to the website now. However, the facets web part and the breadcrumbs web part now show an 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.")

1. Is this also because of a problem with the CAS policy? If so, do you have any suggestions on how I can fix this.

2. I was also wondering - how does the  manifest.xml get updated with the new value of the public key token for the assembly using the process described by shaunocallaghan above? In that procedure, we are changing the value of the key in the assembly components and in the web.config file - not in the manifest. I am not very familiar with this space - could you please explain?

Thanks,
Vaegy
Jun 18, 2008 at 9:54 PM


Vaegy wrote:
I changed the trust level to "Full" and now I can pull up the pages on the website including the search page. So the error I was getting earlier seems to have gone away - at least I can get to the website now. However, the facets web part and the breadcrumbs web part now show an 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.")

1. Is this also because of a problem with the CAS policy? If so, do you have any suggestions on how I can fix this.

2. I was also wondering - how does the  manifest.xml get updated with the new value of the public key token for the assembly using the process described by shaunocallaghan above? In that procedure, we are changing the value of the key in the assembly components and in the web.config file - not in the manifest. I am not very familiar with this space - could you please explain?

Thanks,
Vaegy


Hi Vaegy,

What I suggest you do is remove the Faceted Search and Search Bread Crumb web parts from your web part gallery and then readd them.  This will ensure that the correct assembly, with the correct PublicKeyToken value, is being referenced through SharePoint.  At the moment, I think you've referenced the newly signed assembly in web.config, feature.xml and .webpart files but I think SharePoint may be looking at an old reference.

Manually remove them and readd them (populate gallery) and let me know if that fixes your problem.

Best,

Shaun O'Callaghan
Jun 18, 2008 at 11:43 PM
Edited Jun 18, 2008 at 11:44 PM
Hi Shaun,

Thanks for your reply. After resigning the assembly and updating .webpart files, Feature.xml and web.config (with new token and trust="Full"), I went in and deleted the facets and breadcrumbs webpart. I re-added them manually using populate gallery - but still the same error. I did notice another error last time and again this time when trying to deactivate the "Office SharePoint Server Faceted Search Web Parts" feature (see cut and paste below). I am thinking that it may be that the manifest.xml deployed on the server still has the old public key token for the assembly element (see blue highlighted section in error). I don't see that we changed it anywhere or did anything that could have changed it. Is this correct?

1. If my guess is correct, how can I change the reference in the manifest? Or...
2. Everytime I make a modification to the code, do I need to rebuild the project, create a new solution file .wsp (with a new manifest) and then redeploy?
3. Do you distribute the original public key token so we can sign the assembly with it?

Please let me know what you think.

Thank you!
Vaegy
-------------------------------------------------------------------------------------------------------------------------
Feature '4ad6146d-6ada-4931-ab81-0e179de7008e' could not be installed because the loading of event receiver assembly "Microsoft.SharePoint.Portal.ExtendedSearch, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a646907c4a695009" failed: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.SharePoint.Portal.ExtendedSearch, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a646907c4a695009' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Microsoft.SharePoint.Portal.ExtendedSearch, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a646907c4a695009'
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)
   at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject() 

-------------------------------------------------------------------------------------------------------------------------


shaunocallaghan wrote:


Vaegy wrote:
I changed the trust level to "Full" and now I can pull up the pages on the website including the search page. So the error I was getting earlier seems to have gone away - at least I can get to the website now. However, the facets web part and the breadcrumbs web part now show an 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.")

1. Is this also because of a problem with the CAS policy? If so, do you have any suggestions on how I can fix this.

2. I was also wondering - how does the  manifest.xml get updated with the new value of the public key token for the assembly using the process described by shaunocallaghan above? In that procedure, we are changing the value of the key in the assembly components and in the web.config file - not in the manifest. I am not very familiar with this space - could you please explain?

Thanks,
Vaegy


Hi Vaegy,

What I suggest you do is remove the Faceted Search and Search Bread Crumb web parts from your web part gallery and then readd them.  This will ensure that the correct assembly, with the correct PublicKeyToken value, is being referenced through SharePoint.  At the moment, I think you've referenced the newly signed assembly in web.config, feature.xml and .webpart files but I think SharePoint may be looking at an old reference.

Manually remove them and readd them (populate gallery) and let me know if that fixes your problem.

Best,

Shaun O'Callaghan



Jun 19, 2008 at 6:50 PM
Hi Shaun,

I created a new solution file and redeployed it and it works now.

Thanks,
Vaegy
Jul 15, 2009 at 7:37 AM

how do you rebuild the solution and deploy? did you recreate the wsp? thanks for any help.