문제

SP 2013 팜 솔루션에서 CSOM을 사용하는 것이 가능하다는 것을 알고 있는지 묻는 것을 실행하고자하는 문제가 있습니다.

나는 끊임없이 401 무단 예외를 얻는다.

여기에서 내가 clientContext를 만드는 방법은 다음과 같습니다.

this.webUrl = SPContext.Current.Web.Url;
this.siteUrl = SPContext.Current.Site.Url;

clientContext = new SP.ClientContext(this.webUrl);
clientContext.Credentials = CredentialCache.DefaultNetworkCredentials;
.

SharePoint AutoHosted 앱과 내 농장 솔루션 사이의 코드를 공유하려는 경우 CSOM을 사용해야합니다.

도움이 되었습니까?

해결책

This won't work because of internal security checks of SharePoint, and deactivating them isn't recommended.

Therefore you abstract your main code and create a semi intelligent data binding layer in your class to load the data. Dynamically loading in the required namespace for reading in the data, by using reflection.

System.Reflection.Assembly asmbly;
asmbly = System.Reflection.Assembly.Load("Microsoft.SharePoint")

object clss;
clss = asb.CreateInstance("Microsoft.SharePoint.Foo")

Yes it would be a little more code, but if you abstract it properly and load the data into a List for example, then this code will be minimal.

Reference - Dynamic Namespace Imports and Switching:

http://www.codeproject.com/Articles/32828/Using-Reflection-to-load-unreferenced-assemblies-a

http://www.debenu.com/kb/switching-between-the-32-bit-and-64-bit-dll-versions-of-debenu-quick-pdf-library/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top