C# 无法加载文件或程序集“Microsoft.SharePoint.Library”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1505754/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C# Could not load file or assembly 'Microsoft.SharePoint.Library'
提问by JL.
I am developing on a 64bit version of Windows 7, running MOSS (SharePoint), this is my dev machine.
我正在 64 位版本的 Windows 7 上开发,运行 MOSS (SharePoint),这是我的开发机器。
Now when I deploy my web service app to a test server Windows 2003 32bit (no Sharepoint installed) I get this error.
现在,当我将 Web 服务应用程序部署到测试服务器 Windows 2003 32 位(未安装 Sharepoint)时,出现此错误。
Could not load file or assembly 'Microsoft.SharePoint.Library, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified
无法加载文件或程序集“Microsoft.SharePoint.Library, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”或其依赖项之一。该系统找不到指定的文件
The DLL has clearly been copied to the bin directory (Microsoft.Sharepoint.dll).
DLL 已明确复制到 bin 目录 (Microsoft.Sharepoint.dll)。
Any ideas?
有任何想法吗?
采纳答案by Shiraz Bhaiji
If you are using sharepoint dll's it will only work on a machine with sharepoint installed.
如果您使用的是 sharepoint dll,它只能在安装了 sharepoint 的机器上运行。
Even if you managed to hack it and get it to work, you would probably be breaking a license agreement.
即使你设法破解它并让它工作,你也可能会违反许可协议。
回答by Chris Ballance
Don't mix 64-bit and 32-bit for dev / testing / production. This will never work reliably if at all.
不要将 64 位和 32 位混合用于开发/测试/生产。如果有的话,这将永远不会可靠地工作。
回答by mfeingold
Well what about other dlls referenced by the Sharepoint dll? With long dependency chains it can be quite difficult to diagnose these sort of problems. In such situations I find the fusion log viewer extremely useful. It is a part of framework SDK - open the SDK Command prompt and type fuslogvw. It is pretty obvious from there
那么 Sharepoint dll 引用的其他 dll 呢?对于长依赖链,诊断此类问题可能非常困难。在这种情况下,我发现融合日志查看器非常有用。它是框架 SDK 的一部分 - 打开 SDK 命令提示符并键入 fuslogvw。从那里很明显
回答by Ade Miller
This is almost certainly a dependency issue. The DLL is dependent on another DLL which isn't in the GAC or on the probing path. The two tools you need to figure this out are FUSLOGVW.EXE and Process Monitor
这几乎可以肯定是一个依赖问题。DLL 依赖于不在 GAC 或探测路径中的另一个 DLL。您需要解决这个问题的两个工具是 FUSLOGVW.EXE 和 Process Monitor
Fusion Log viewer will allow you to look at assembly bind successes and failures as your application loads. It's part of the Windows SDK.
Fusion Log 查看器将允许您在应用程序加载时查看程序集绑定成功和失败。它是 Windows SDK 的一部分。
http://msdn.microsoft.com/en-us/library/e74a18c4(VS.71).aspx
http://msdn.microsoft.com/en-us/library/e74a18c4(VS.71).aspx
FUSLOGVW needs admin privs to run correctly.
FUSLOGVW 需要管理员权限才能正确运行。
If that doesn't work another tactic is to use Process monitor to look at which files aren't getting loaded and which folders are being searched.
如果这不起作用,另一种策略是使用进程监视器来查看哪些文件没有被加载以及哪些文件夹正在被搜索。
http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
However. Without SharePoint installed I wouldn't expect this to work.
然而。如果没有安装 SharePoint,我不希望这会起作用。
Ade
阿德
回答by Eli
There is a way to load Sharepoint libraries in a development console with windows XP, Vista or Seven.
有一种方法可以在 Windows XP、Vista 或 Seven 的开发控制台中加载 Sharepoint 库。
请参阅此处:http: //fernandof.wordpress.com/2008/02/11/how-to-install-the-sharepoint-2007-vs-2005-extensions-on-a-workstation/
[O]pen the regedit and create the following keys and the string value:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions.0] "Sharepoint"="Installed"
That's it! You have fooled the installer into running on a workstation. Easy. I also recommend adding the core SharePoint assemblies into the [GAC] using gacutil. Those assemblies can be found by default in any [SharePoint] machine under the folder:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI
.
[O]打开regedit并创建以下键和字符串值:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions.0] "Sharepoint"="Installed"
就是这样!您已欺骗安装程序在工作站上运行。简单。我还建议使用 gacutil 将核心 SharePoint 程序集添加到 [GAC] 中。默认情况下,可以在以下文件夹下的任何 [SharePoint] 计算机中找到这些程序集:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI
.
回答by Martin R-L
From MSDN: "The CI build environment for the Training Management application does not perform any tests that require a live instance of SharePoint. All the unit tests use mocks that replace the actual SharePoint instance and services. Building the code and running the unit tests only requires that the following SharePoint assemblies are installed on the CI build server:
来自 MSDN:“培训管理应用程序的 CI 构建环境不执行任何需要 SharePoint 实时实例的测试。所有单元测试都使用模拟来替换实际的 SharePoint 实例和服务。仅构建代码并运行单元测试要求在 CI 生成服务器上安装以下 SharePoint 程序集:
Microsoft.SharePoint
微软SharePoint
Microsoft.SharePoint.Security
Microsoft.SharePoint.Security
Microsoft.SharePoint.WorkflowActions
Microsoft.SharePoint.WorkflowActions
Supporting referenced assemblies"
支持引用的程序集”