简体   繁体   English

将dll部署到GAC

[英]Deploying dlls to GAC

We have a Sharepoint 2010 solution that we are trying to the deploy to the production environment. 我们有一个Sharepoint 2010解决方案,我们正在尝试将其部署到生产环境中。

We have developed this solution using Visual Studio 2010 and we have created several projects which result in a number of dlls. 我们已经使用Visual Studio 2010开发了该解决方案,并且创建了多个项目,这些项目导致大量的dll。

We are getting the following error when accessing one of the web parts. 访问其中一个Web部件时,出现以下错误。

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. 类型“ xxxx”是在未引用的程序集中定义的。 You must add a reference to assembly 'xxx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxx'. 您必须添加对程序集'xxx,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = xxxx'的引用。

For installing the dlls - I have dragged and dropped them into the GAC. 对于安装dll,我将它们拖放到了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? 也许有更好的方法安装到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. 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):错误CS0012 :类型“ xxxx”在未引用的程序集中定义。 You must add a reference to assembly 'xxxx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=fe560f99f37381ef'. 您必须添加对程序集'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 在System.Web.Compilation.BuildProviders.System.Web.Compilation.BuildProvidersCompiler.PerformBuild()在System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)在System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath) virtualPath,布尔值noBuild,布尔值allowCrossApp,布尔值allowBuildI ... a47a805d-765d-429e-b080-fe031b3e4fac

Thanks, 谢谢,

Joseph 约瑟夫

You should be creating WSP packages with Visual Studio 2010 for your SharePoint 2010 solutions. 您应该使用Visual Studio 2010为您的SharePoint 2010解决方案创建WSP程序包。 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. 为此,请双击SharePoint项目中的“程序包”,然后转到“高级”选项卡。 From here you will be able include external assemblies into your WSP, or automatically include the output from other projects in your solution. 从这里,您将可以将外部程序集包含到WSP中,或者自动将解决方案中其他项目的输出包含在内。

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. 如果要引用可由多个WSP解决方案共享的程序集,请注意以下特殊警告:撤消WSP时,无论另一个WSP是否也包含该程序集,WSP中包含的所有程序集也会被撤消。

My recommended best practice for a shared assembly is to create a standalone WSP solution which contains nothing but the assemblies. 对于共享程序集,我建议的最佳实践是创建一个独立的WSP解决方案,该程序只包含程序集。 Create a new empty SharePoint project. 创建一个新的空SharePoint项目。 Click on the project in the Solution Explorer, and view the properties pane using F4. 单击解决方案资源管理器中的项目,然后使用F4查看属性窗格。 Set "Include assembly in package" to false and "Assembly Deployment Target" to GlobalAssemblyCache. 将“在程序包中包含程序集”设置为false,将“程序集部署目标”设置为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. 您最终将需要多个WSP来部署解决方案,但这有助于以可靠的方式处理依赖性。

You should never use manually adding assemblies to the GAC as your production deployment method!! 您绝不应使用将装配体手动添加到GAC作为生产部署方法!!

Since you mention that you already tried deploying the assemblies from WSP, I thought I would list another possibility as a new answer. 既然您提到您已经尝试过从WSP部署程序集,所以我想我将列出另一种可能性作为新答案。 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. 您首先需要确定缺少哪个程序集,然后验证该程序集是否存在于所有前端的GAC中。 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? 接下来,您的Web部件是如何开发的,您确定其Web部件会引发该错误吗? Specifically, are you using any .ascx markup in your web part to reference controls out of this 'missing' assembly? 具体来说,您是否在Web部件中使用任何.ascx标记来引用此“缺失”程序集中的控件? 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. 如果是这样,您可能需要确保在标记中添加<%@ Assembly Name="" %>指令,以使asp.net编译器知道在编译期间引用它。 You may potentially need to add SafeControl entries also. 您可能还需要添加SafeControl条目。

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. 将程序集放入GAC的首选方法是使用应用程序安装程序:)请注意,您需要提升的特权才能将程序集安装到GAC。 You can also use gacutil. 您也可以使用gacutil。

Order of GAC'ing assemblies shouldn't matter. GAC组装程序的顺序无关紧要。

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. 根据错误,您可能缺少必要的程序集-使用FusLogVw或Reflector之类的工具来确定未部署的依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM