We have a Sharepoint 2010 solution that we are trying to the deploy to the production environment.
We have developed this solution using Visual Studio 2010 and we have created several projects which result in a number of dlls.
We are getting the following error when accessing one of the web parts.
An error occurred during the compilation of the requested file, or one of its dependencies. The type 'xxxx' is defined in an assembly that is not referenced. You must add a reference to assembly 'xxx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxx'.
For installing the dlls - I have dragged and dropped them into the GAC. Is this a good approach? Could it be the cause of the problem? perhaps there is a better way of installing into the GAC? Or perhaps they need to be installed in a particular order?? The one without dependencies first?
This is the full error from the log file:
System.Web.HttpCompileException: c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\6f2f2743\7b5d4663\App_Web_rxpractioncommonwpusercontrol.ascx.12f7e65c.q7c1p6i0.0.cs(134): error CS0012: The type 'xxxx' is defined in an assembly that is not referenced. You must add a reference to assembly 'xxxx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=fe560f99f37381ef'. at System.Web.Compilation.AssemblyBuilder.Compile() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildI... a47a805d-765d-429e-b080-fe031b3e4fac
Thanks,
Joseph
You should be creating WSP packages with Visual Studio 2010 for your SharePoint 2010 solutions. You could include the referenced assemblies as part of your main package. To do this, double click on the Package in your SharePoint project, and go to the advanced tab. From here you will be able include external assemblies into your WSP, or automatically include the output from other projects in your solution.
If you are referencing assemblies which could be shared by multiple WSP solutions, be careful of this particular caveat: When a WSP is retracted, all included assemblies in the WSP are also retracted regardless of whether or not another WSP also includes the assembly.
My recommended best practice for a shared assembly is to create a standalone WSP solution which contains nothing but the assemblies. Create a new empty SharePoint project. Click on the project in the Solution Explorer, and view the properties pane using F4. Set "Include assembly in package" to false and "Assembly Deployment Target" to GlobalAssemblyCache. Then double click on the package, and go to the advanced tab to add your assembly references.
You will end up with more than one WSP to deploy your solution, but this helps deal with dependencies in a reliable way.
You should never use manually adding assemblies to the GAC as your production deployment method!!
Since you mention that you already tried deploying the assemblies from WSP, I thought I would list another possibility as a new answer. You are going to need to be specific about which assembly is missing first of all, and then validate that this assembly is present in the GAC of all your front ends. You need to rule out any possibility that the reference assembly actually is missing. Use the fusion log viewer as was mentioned in another answer.
Next, how was your web part developed and are you sure its the web part throwing that error? Specifically, are you using any .ascx markup in your web part to reference controls out of this 'missing' assembly? If so, you may need to be sure to add a
<%@ Assembly Name="" %>
directive to your markup so that the asp.net compiler knows to reference it during compilation. You may potentially need to add SafeControl entries also.The preferred way of getting assemblies into the GAC would be with an application installer :) Note that you need elevated privileges to install assemblies to the GAC. You can also use gacutil.
Order of GAC'ing assemblies shouldn't matter.
As per the error, you might be missing a prerequisite assembly - use FusLogVw or a tool like Reflector to determine which dependencies aren't deploying.