简体   繁体   中英

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

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?

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.

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 .

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

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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