c# - Bogus (?) File Not Found error when trying to do client SharePoint coding -
c# - Bogus (?) File Not Found error when trying to do client SharePoint coding -
i getting think bogus "file not found" error when simple sharepoint 2010 client coding. not i'm building wrong cpu type or wrong .net version. (i'm building "any cpu" or "x64" , .net 3.5.) copied microsoft.sharepoint*.dlls server , set them in c:\program files\common files\microsoft shared\web server extensions\14\isapi. (i've tried other folders too.) opened visual studio 2010 project, right-clicked on references, clicked browse tab , added 1 or of dlls (i should need microsoft.sharepoint.dll.) simple programme seek run:
using system; using system.collections.generic; using system.linq; using system.text; using microsoft.sharepoint; namespace spliststoconsole { class programme { static void main( string[] args ) { using ( spsite sc = new spsite( "http://orsandbox01/sitepages/home.aspx" ) ) { spweb site = sc.rootweb; foreach ( splist list in site.lists ) { if ( !list.hidden ) { console.writeline( list.title ); } } } } } }
and here error get:
unhandled exception: system.io.filenotfoundexception: not load file or assembly 'microsoft.sharepoint.library, version=14.0.0.0, culture=neutral, publickeytoken=71e9bce111e9429c' or 1 of dependencies. scheme cannot find file specified. file name: 'microsoft.sharepoint.library, version=14.0.0.0, culture=neutral, publickeytoken=71e9bce111e9429c' @ spliststoconsole.program.main(string[] args) wrn: assembly binding logging turned off. enable assembly bind failure logging, set registry value [hklm\software\microsoft\fusion!enablelog] (dword) 1. note: there performance penalty associated assembly bind failure logging. turn feature off, remove registry value [hklm\software\microsoft\fusion!enablelog].i haven't done sharepoint coding before i've next instructions can google. tia help can share.
use sharepoint web services instead of object model
if need work remote sharepoint server, can utilize web services instead of object model.
assuming have added reference lists webservice (/_vti_bin/lists.asmx), , called "lists", can list of visible lists this:
lists.lists proxy = new lists.lists(); // utilize logged on users credentials authenticate sharepoint proxy.credentials = credentialcache.defaultnetworkcredentials; xmlnode listcollection = proxy.getlistcollection(); foreach (xmlnode node in listcollection.childnodes) { bool hidden = bool.parse(node.attributes["hidden"].value); if (!hidden) { console.writeline(node.attributes["title"].value); } }
you can find more details on lists web service here: http://msdn.microsoft.com/en-us/library/lists.lists_methods.aspx
most of things can object model code can achieved using web services.
adding reference web serviceto add together web reference in vs2010:
right click on project node in solution explorer, , select add service reference
in add service reference dialog, click on advanced...
in service reference settings dialog, click on add web reference...
in add web reference dialog:
a. url, come in site collection url followed _vti_bin/lists.asmx. example: http://sharepoint/sites/mysitecollection/_vti_bin/lists.asmx
b. web reference name, come in lists
c. click add reference
the reference added project, , can utilize code above access it.
to lists sub-site, alter services url property point web service sub-site adding _vti_bin/lists.asmx sub-site's url above.
c# visual-studio-2010 sharepoint-2010
Comments
Post a Comment