C# Could not load file or assembly 'Microsoft.SharePoint.Library'

僤鯓⒐⒋嵵緔 提交于 2020-01-01 12:10:12

问题


I am developing on a 64bit version of Windows 7, running MOSS (SharePoint), this is my dev machine.

Now when I deploy my web service app to a test server Windows 2003 32bit (no Sharepoint installed) I get this error.

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

The DLL has clearly been copied to the bin directory (Microsoft.Sharepoint.dll).

Any ideas?


回答1:


If you are using sharepoint dll's it will only work on a machine with sharepoint installed.

Even if you managed to hack it and get it to work, you would probably be breaking a license agreement.




回答2:


There is a way to load Sharepoint libraries in a development console with windows XP, Vista or Seven.

See here: 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\12.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.




回答3:


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

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.

http://msdn.microsoft.com/en-us/library/e74a18c4(VS.71).aspx

FUSLOGVW needs admin privs to run correctly.

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

However. Without SharePoint installed I wouldn't expect this to work.

Ade




回答4:


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:

Microsoft.SharePoint

Microsoft.SharePoint.Security

Microsoft.SharePoint.WorkflowActions

Supporting referenced assemblies"

http://msdn.microsoft.com/en-us/library/ff647619.aspx




回答5:


Don't mix 64-bit and 32-bit for dev / testing / production. This will never work reliably if at all.




回答6:


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



来源:https://stackoverflow.com/questions/1505754/c-sharp-could-not-load-file-or-assembly-microsoft-sharepoint-library

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!