tag:blogger.com,1999:blog-80067242559309215482023-10-03T19:26:43.028+08:00遺忘技術的角落寬廣無際的技術翰海中,能遺忘的就把它遺忘掉吧~
無法遺忘的,總會有個角落,靜靜地等候著~亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.comBlogger161125tag:blogger.com,1999:blog-8006724255930921548.post-33997342590473772562018-07-18T01:47:00.001+08:002018-07-18T01:52:05.783+08:00Multiple assemblies with equivalent identity have been imported 解決方式最近為了開發測試一個功能,從NuGet上下載安裝了某一個package包,因為這個package包的說明書中指定要使用 .NET 4.6.2,我就先下載安裝了 .NET 4.6.2,並且建立專案,安裝 XXX NuGet,結果在 Compiler的時候,就出現了以下的錯誤訊息:<span style="color: red;">Multiple assemblies with equivalent identity have been imported</span><br />
<a href="https://3.bp.blogspot.com/--B6zhd7wbIs/W04qHtmfTcI/AAAAAAABALI/BtSGgDpl8Hk8TDuDLZTJTgq9NU7VLhRAQCLcBGAs/s1600/ERROR.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="143" data-original-width="676" src="https://3.bp.blogspot.com/--B6zhd7wbIs/W04qHtmfTcI/AAAAAAABALI/BtSGgDpl8Hk8TDuDLZTJTgq9NU7VLhRAQCLcBGAs/s1600/ERROR.png" /></a><br />
<br />
<br />
<br />
<br />
<br />
上網一查,原來很多人都遇到這問題,紀錄一下解決方式:<br />
1. 打開VS專案的 .csproj<br />
2. 在 PropertyGroup 區段中,加入ImplicitlyExpandDesignTimeFacades 這個設定,並設定為 false:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-p4eVBT2IURc/W04smQTnHqI/AAAAAAABALU/G7dCEupKOhwE0DDzDRwYOmex6UiFEd6PQCLcBGAs/s1600/ERROR.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="365" data-original-width="697" src="https://1.bp.blogspot.com/-p4eVBT2IURc/W04smQTnHqI/AAAAAAABALU/G7dCEupKOhwE0DDzDRwYOmex6UiFEd6PQCLcBGAs/s1600/ERROR.png" /></a></div>
<br />
3. 重新建置,就可以了!<br />
相關參考連結:<br />
https://github.com/dotnet/sdk/issues/1539<br />
https://stackoverflow.com/questions/39252032/where-do-i-set-implicitlyexpanddesigntimefacades-to-false/44648397#44648397<br />
<br />亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-83067428503132753682016-09-04T15:32:00.001+08:002016-09-04T15:41:30.690+08:00Create Azure WebJob using C# (使用C#開發 Azure WebJob 執行背景工作)<p><a href="https://azure.microsoft.com/zh-tw/documentation/articles/websites-webjobs-resources/">WebJobs</a> 是一項 Azure App Service 功能,可讓您在與 Web 應用程式、API 應用程式或行動應用程式相同的內容中執行程式或指令碼,舉個簡單例子來說,以往我們要排程一個簡單的exe應用程式,固定一段時間執行一次,或者是每隔10min執行一次,通常的做法會寫一個exe,然後在Windows上直接設定OS的排程去執行此應用程式,或者是在此應用程式中,自己寫Timer去控制執行某段功能的時間,但主要的EXE還是執行在您的機器上,有著諸多的限制。</p> <p>現在換一個想法,假設我們想要排程的應用程式可以放在雲端上,透過簡單的排程或是自己寫的邏輯,就可以達到這樣的效果,這樣不是很方便嗎? 沒錯Azure WebJob 就是這樣的一個服務,最簡單的方式就是把你的應用程式,例如:exe,包成zip檔,上傳到App Service Web ,然後設定一下就可以了,No Code的設定方式可參考以下Azure官方介紹:<a title="https://azure.microsoft.com/zh-tw/documentation/articles/web-sites-create-web-jobs/" href="https://azure.microsoft.com/zh-tw/documentation/articles/web-sites-create-web-jobs/">https://azure.microsoft.com/zh-tw/documentation/articles/web-sites-create-web-jobs/</a></p> <p>但假設透過Azure上的排程器工作集合,免費的排程是有一些條件限制的,假設要比較多的排程功能,可能需要一些費用的產生,排程器工作集合有不同的收費等級。</p> <p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://lh3.googleusercontent.com/-EmET9tGj_4s/V8vQKdn-0xI/AAAAAAAA9n4/Y8ycbTEM4MM/image%25255B65%25255D.png?imgmax=800" width="377" height="117" /></p> <p>因此如果我們將程式部署上去之前,背景執行的執行相關工作由程式自行控制,那麼也不失是另一種折衷的方式,這時就要使用到 WebJob SDK。以下這段話是微軟官方的介紹:<a href="https://azure.microsoft.com/zh-tw/documentation/articles/websites-webjobs-resources/">WebJobs SDK</a> 的目的是為了簡化您為 WebJob 可執行的一般工作 (例如影像處理、佇列處理、RSS 彙總、檔案維護及傳送電子郵件) 撰寫的程式碼。WebJobs SDK 具有內建功能,用於處理 Azure 儲存體和服務匯流排、工作排程和處理錯誤,以及許多其他常見案例。此外,它已被設計成可延伸。<a href="https://github.com/Azure/azure-webjobs-sdk/">WebJobs SDK 是開放原始碼</a>,並且有<a href="https://github.com/Azure/azure-webjobs-sdk-extensions/wiki/Binding-Extensions-Overview">擴充功能的開放原始碼儲存機制</a>。</p> <p>WebJobs SDK 包含下列元件:</p> <ul> <li> <p><strong>NuGet 封裝:</strong>新增至 Visual Studio 主控台應用程式專案的 NuGet 封裝,會利用 WebJobs SDK 屬性修飾方法,提供一個程式碼使用的架構。</p> </li> <li> <p><strong>儀表板:</strong>Azure App Service 中包含部分的 WebJobs SDK,該部份項目可針對使用 NuGet 封裝的程式提供豐富的監控和診斷功能,無需撰寫程式碼就可以使用這些監視和診斷功能。</p> </li> </ul> <p>當針對WebJob SDK有些概念後,以下亞當斯就來介紹一下使用C#搭配WebJobs SDK開發WebJob的簡易方式和步驟:</p> <p>1.新增專案時,選取Azure WebJob專案範本:</p> <p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://lh3.googleusercontent.com/-vz3g9hyXnSA/V8vOCJ84h3I/AAAAAAAA9ng/xXb73TFwwy8/image%25255B60%25255D.png?imgmax=800" width="543" height="353" /></p> <p>2.當專案建立完成時,在Program.cs中會自動加入JobHost的物件,JobHost 物件是一組背景功能的容器,JobHost 物件可監視功能、注意可觸發功能的事件,以及發生觸發事件時執行功能。</p> <p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://lh3.googleusercontent.com/-rytYj5WYgls/V8vODWW31HI/AAAAAAAA9nk/6ffyJMGy6-A/image%25255B45%25255D.png?imgmax=800" width="332" height="199" /></p> <p>3.在Functions.cs中加入以下這段我們想要自行定義的程式碼,宣告方法為非同步工作,並且在方法上加上:NoAutomaticTrigger的Attribute,程式中我們使用While搭配await Task.Delay(TimeSpan.FromSeconds(10))讓每10秒去重複執行一次。</p> <p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://lh3.googleusercontent.com/-VH1ISDIxL7s/V8vOEkYC1EI/AAAAAAAA9no/hDBox9kWrJQ/image%25255B50%25255D.png?imgmax=800" width="795" height="315" /></p> <p>4.當寫好我們預計要固定執行的方法之後,要回到Program.cs,針對指定的方法去呼叫,程式碼如下:</p> <p>var host = new JobHost();                        <br /><font color="#ff0000">host.CallAsync(typeof(Functions).GetMethod("ProcessMethod"));</font> <br />host.RunAndBlock();</p> <p>5.最後再測試執行之前,我們要先設定好App.Config中的兩個連線字串,分別為:AzureWebJobsDashboard、AzureWebJobsStorage,將這兩個連線設定,指到雲端上的某一個儲存體即可!</p> <p><add name="<font color="#ff0000">AzureWebJobsDashboard</font>" connectionString="DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=xxx /> <br /><add name="<font color="#ff0000">AzureWebJobsStorage</font>" connectionString="DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=xxx /></p> <p>6. 最後,將專案Compiler,並且直接執行進行測試,可看到執行起來的結果如下,偵測到ProcessMethod方法開始執行,然後根據自訂邏輯每10秒執行一次功能,輸出counter到畫面中。</p> <p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://lh3.googleusercontent.com/-wBlqL6FdnaY/V8vOGQNL_EI/AAAAAAAA9ns/e9vbWwqju28/image%25255B55%25255D.png?imgmax=800" width="669" height="181" /></p>亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-40205947952102264682015-09-04T00:01:00.001+08:002015-09-04T00:01:16.379+08:00SharePoint 2103 Folder or File Limit Lenght (SharePoint文件庫中檔案或資料夾的長度限制)<p>在SharePoint 2013的文件庫或是清單中,有一些比較常見的限制,例如:Item : 30,000,000 per list…等等,但是說明中並沒有列出文件庫的資料夾或是檔案的長度限制,而這邊實際測試的結果,當資料夾(包含巢狀式結構)的長度大於260的話,就無法繼續新增下去!</p> <p><img title="SPFolder" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="SPFolder" src="http://lh3.googleusercontent.com/-g1VIGOKODd4/VehuxjA0AUI/AAAAAAAA5Oo/md0Md0H96L0/SPFolder%25255B13%25255D.png?imgmax=800" width="502" height="274" /></p> <p>檔案同樣也是,在巢狀式結構中,檔案名稱所對應的路徑假設大於260的話</p> <p><img title="SPFile" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="SPFile" src="http://lh3.googleusercontent.com/-_bdbDT0SEX0/VehuynlZviI/AAAAAAAA5Ow/_k2DpuYQ8p4/SPFile%25255B7%25255D.png?imgmax=800" width="617" height="433" /></p> <p>參考資料:</p> <p><a href="https://technet.microsoft.com/en-us/library/cc262787.aspx">Software boundaries and limits for SharePoint 2013</a></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-7531730111435925502015-09-02T11:40:00.001+08:002015-09-02T11:40:45.110+08:00Office使用RMS發生The operation being requested was not performed because the user has not been authenticated.<p>當使用Office文件,嘗試使用Word 然後想要去使用RMS執行限制存取,可以在檔案-->資訊-->保護文件—>限制存取—>連線至數位版權管理伺服器</p> <p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.googleusercontent.com/-pho9nLaTPpI/VeZvsycn-rI/AAAAAAAA5OA/QrflYsd0uzA/image%25255B19%25255D.png?imgmax=800" width="598" height="500" /></p> <p>但發生了以下的錯誤訊息:The operation being requested was not performed because the user has not been authenticated.</p> <p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.googleusercontent.com/-WXZvOk7Ew8Y/VeZvt3lsLPI/AAAAAAAA5OI/9tcvuAI5mtg/image%25255B21%25255D.png?imgmax=800" width="443" height="159" /></p> <p>解決問題的方式為將此RMS的授權和驗證的WS路徑,加入到瀏覽器的Local Intranet Zone中即可!</p> <p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.googleusercontent.com/-uiojP525p0o/VeZvuzsKoBI/AAAAAAAA5OQ/sak_7CvUhOs/image%25255B24%25255D.png?imgmax=800" width="348" height="306" /></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-85364829599185514882015-09-01T17:49:00.001+08:002015-09-01T17:49:50.516+08:00SharePoint How to avoid restart Application pools when use Update-SPSolution (SharePoint 使用Update-SPSolution時避免啟動Application pools on IIS)<p>開發好的SP客製化專案(以WebPart為例來說),封裝完成為WSP,在SharePoint部署上去之後,假設需要更新的話,可以使用Update-SPSolution 指令來進行WebPart的更新,指令參考如下:</p> <p>Update-SPSolution -Identity MyWP.wsp -LiteralPath D:\MyWP.wsp –GACDeployment</p> <p>但是此時會遇到一個問題,假設我們一開始是把此WebPart部署到SharePoint-80這一個WebApplication,但是當執行Update-SPSolution時,系統並不會只是單純的SharePoint-80單一Web Application Restart,而是會預設將此Server上所有的Application Pool全部進行:停止—>啟用,如下圖所示:</p> <p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.googleusercontent.com/-1xqtK0x-kpU/VeV0q1WZcVI/AAAAAAAA5NQ/iQHsNym4UsY/image%25255B12%25255D.png?imgmax=800" width="335" height="240" /></p> <p>原因是因為所有預設開發專案並且封裝WSP時,有一個封裝屬性:ResetWebServerModeOnUpgrade預設值是:StartStop,此時將會影響所有此Server上的Web Application連帶影響其他的應用程式! </p> <p>那麼該如何來解決執行Update-SPSolution時避免去重新啟動所有的Application Pool呢? 執行步驟如下:</p> <p>1. 開啟客製化的專案,開啟專案中的Package.Template.xml</p> <p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.googleusercontent.com/-d_Os4M1mnY0/VeV0r8O5l0I/AAAAAAAA5NY/H1oynjgo7_U/image%25255B7%25255D.png?imgmax=800" width="214" height="111" /></p> <p>2. 設定以下三個屬性值:ResetWebServer="FALSE" 、ResetWebServerModeOnUpgrade="Recycle" 、DeploymentServerType="WebFrontEnd",如下圖所示:</p> <p><a href="http://lh3.googleusercontent.com/-JjYpYMmzUe4/VeV0s4Ku-QI/AAAAAAAA5Ng/32gH_BI5gE4/s1600-h/image9%25255B3%25255D.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.googleusercontent.com/-zJJSuQB_YLg/VeV0uAWyKnI/AAAAAAAA5No/WjVc9VeYOOY/image9_thumb%25255B2%25255D.png?imgmax=800" width="464" height="146" /></a></p> <p>3. 此時重新打包封裝,並且針對更新後的WSP進行部署! </p> <p>Update-SPSolution -Identity MyWP.wsp -LiteralPath D:\MyWP.wsp –GACDeployment</p> <p>此時就可以IIS檢視,可以發現執行Update-SPSolution並不會將Application Pool停止了! Good!</p> <img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.googleusercontent.com/-moUIAzoxzEw/VeV0vBBU1II/AAAAAAAA5Nw/6wnJSmgJR5A/image11%25255B5%25255D.png?imgmax=800" width="338" height="235" /> <p> </p> <p>參考資料:</p> <p><a title="https://msdn.microsoft.com/en-us/library/ms412929.aspx" href="https://msdn.microsoft.com/en-us/library/ms412929.aspx">https://msdn.microsoft.com/en-us/library/ms412929.aspx</a> <br /><a title="http://blog.mastykarz.nl/optimizing-deploying-sharepoint-packages-minimize-impact-farm-availability/" href="http://blog.mastykarz.nl/optimizing-deploying-sharepoint-packages-minimize-impact-farm-availability/">http://blog.mastykarz.nl/optimizing-deploying-sharepoint-packages-minimize-impact-farm-availability/</a></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-77476755600277064262015-08-13T16:46:00.001+08:002015-08-13T16:46:00.411+08:00SharePoint 2013 Custom Search MySite Note (在SharePoint中搜尋MySite注意事項)<p>這兩天在寫客製化Custom Search API,需求是去搜尋MySite的People資料,且Profile資料中有自訂的欄位,不過一直遇到一個問題就是:明明Profile欄位建立,也設定了Search的Metadata,但是結果就是搜尋不到!</p> <p>因此去查詢Search的編目紀錄檔,發現有一個Warning,點進去一看</p> <p>咦! MySite不在編目範圍中?? (註:開發環境是朋友建立的,因此一開始並不清楚預先的設定)</p> <p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.googleusercontent.com/-Tjn9bWAXxec/VcxZLkGSy-I/AAAAAAAA31c/N3pvH1xhoDk/image%25255B5%25255D.png?imgmax=800" width="587" height="198" /></p> <p>也就是說,MySite的SiteCollection下目前不在編目範圍中,因此回到MySite的網站設定—>搜尋—>搜尋與離線可用性</p> <p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.googleusercontent.com/-tJZxkqgKmxI/VcxZMYbK1fI/AAAAAAAA31k/-p0jEbfJf3g/image%25255B10%25255D.png?imgmax=800" width="189" height="170" /></p> <p>將"是否允許此網站顯示在搜尋結果中"改設定為:是!! </p> <p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.googleusercontent.com/-Qa0OmVVaYJc/VcxZNQp1rXI/AAAAAAAA31s/BJNxAuT86bg/image%25255B16%25255D.png?imgmax=800" width="521" height="158" /></p> <p>再回到Search重新Craw一次,上述的警示訊息就不見了,且搜尋的項目結果,也抓到了,雖然是一個小小的設定,但是因為是在MySite的網站中,所以大概稍微紀錄一下這次的Issue。</p> <p><a href="http://lh3.googleusercontent.com/-YqBAQMBJx6M/VcxZPInIlFI/AAAAAAAA310/-NvV29CVR34/s1600-h/image%25255B24%25255D.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.googleusercontent.com/-OWZO74sa56Q/VcxZP0flsjI/AAAAAAAA318/1dw1xcSAM9E/image_thumb%25255B10%25255D.png?imgmax=800" width="648" height="309" /></a><a href="http://lh3.googleusercontent.com/-tGmfo9cQHYY/VcxZQ5aq9KI/AAAAAAAA32E/CF5BFFguqVk/s1600-h/image%25255B25%25255D.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.googleusercontent.com/-R_TbIjNeI6U/VcxZR7puoLI/AAAAAAAA32M/VM-mihEpVlY/image_thumb%25255B11%25255D.png?imgmax=800" width="648" height="309" /></a></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-6931985351536708522015-06-17T14:52:00.000+08:002015-07-20T02:52:58.008+08:00Adding a Feature Event Receiver and Deploying Debugging SP Projects(SharePoint新增Feature事件接收器以及進行專案偵錯)<p>這一篇的內容主要是介紹在SharePoint的webpart專案中,在其Feature中加入事件接收器,並在這些事件中去撰寫程式去改變網站中的一些資訊,例如:title、logo之類的做法。</p> <p>另外,也介紹的如何針對SharePoint客製化專案進行程式碼的偵錯,就讓咱們的一起來複習一下囉!!!</p> <p><iframe height="315" src="https://www.youtube.com/embed/iw8FkWF-xVM" frameborder="0" width="420" allowfullscreen="allowfullscreen"></iframe></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-63930508007586462792015-06-03T16:46:00.000+08:002015-07-20T02:47:22.208+08:00Using Visual Studio to creating a SharePoint Project(使用vs.net建立sharepoint專案)<p>基本上亞當斯教了這麼多年的SharePoint開發課程,從SharePoint 2003客製化開發,一直到現今的SharePoint 2013客製化開發,算一算玩微軟SharePoint這產品,已經正式邁入第十個年頭了。</p> <p>這麼多年來,幾乎每一年都有進行SharePoint客製化開發教學,事實上現在的網路資訊很發達,隨處可找到相關的資料,不過,如果是自學者可能會想說:是否有step by step的教學? 這樣學習是否更方便呢? </p> <p>沒錯,基於此想法,亞當斯將以往一些基礎的教學過程,曾經有部分錄製下來,接下來就在這個blog分享給有興趣的朋友,內容的話都是一些我曾經上課教過的東西,如果有曾經上過課的學員有看到這幾篇影片,也可以算是複習一下囉!!</p> <p>使用VS.NET 建立 sharepoint 開發專案:</p> <p><iframe height="315" src="https://www.youtube.com/embed/0IPFnzn1dD8" frameborder="0" width="420" allowfullscreen="allowfullscreen"></iframe></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-17367121145331428272015-05-20T18:05:00.000+08:002015-07-20T03:06:12.716+08:00OWASP TOP 10 十大網路應用系統安全弱點 Demo 10<p>OWASP Top 10 主要目的,是將最常見的網路應用系統安全弱點列出,並提供基本的方法保護防止這些弱點,是軟體開發安全計劃最好的開始。</p> <p>以下針對第十點的弱點,做一些簡單的說明和示範:</p> <p>10. Failure to Restrict URL Access:應用程式敏感地區是被保護的Links或是URLs,而這些是不會提供給未被授權的使用者。這也容易讓攻擊者利用這項弱點進入,並進行未被授權的行為。</p> <p><iframe height="315" src="https://www.youtube.com/embed/q08FJTeHv5g" frameborder="0" width="420" allowfullscreen="allowfullscreen"></iframe></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-46024753509033226962015-05-20T03:23:00.000+08:002015-07-20T00:25:34.135+08:00Different User Can View Different Ribbon in SharePoint(SharePoint 根據不同的使用者權限檢視不同的Ribbon功能項)<p>通常在實際的專案需求上,SharePoint Ribbon上的功能並不是全部都開放給全部的使用者可以操作,有時候因為不同權限的關係,或是公司內部ERP上的整合,甚至企業HR人事的架構不同,都希望可以每個不同的使用者進來瀏覽SharePoint 之後,可以有不同的Ribbon可以操作。</p> <p>但是預設SharePoint Ribbon是統一開放給使用者,因此若是想要根據不同的使用者權限檢視不同的Ribbon功能項的話,那麼該如何來設計了?以下為實作:</p> <p>1. 因為每一個Page的Ribbon控管可能都不同,因此這邊使用WebPart放置到頁面來啟用此效果,先建立一個視覺化的網頁組件:</p> <p><img title="clip_image001" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image001" src="http://lh3.googleusercontent.com/-Jcg1kLQguuY/VavPVkWStLI/AAAAAAAA3w4/e6NVU5CT3Pg/clip_image001%25255B12%25255D.png?imgmax=800" width="245" height="262" /></p> <p>2. 先來看一下<a href="http://sharepoint/default.aspx">http://sharepoint/default.aspx</a>瀏覽的畫面,在Ribbon的部分如下圖所示,一般的使用者若是沒有特別的控管,那麼可以檢視以下的「編輯」和「管理」的功能:</p> <p><img title="clip_image003" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image003" src="http://lh3.googleusercontent.com/-lzeT5zJR0C8/VavPX8xvX2I/AAAAAAAA3xA/fmFjrVuHSSw/clip_image003%25255B12%25255D.jpg?imgmax=800" width="558" height="189" /></p> <p>3. 在RibbonWebPartUserControl.ascx.cs的Page_Load加入以下程式碼,透過SPRibbon取得目前的Ribbon物件之後,再透過叫用TrimById的方法將某些Ribbon控制項隱藏:</p> <p>protected void Page_Load(object sender, EventArgs e) <br />{ <br />    SPRibbon currentRibbon = SPRibbon.GetCurrent(this.Page); <br />    if (currentRibbon != null) <br />    { <br />       <br />        if (SPContext.Current.Web.CurrentUser.Name.ToLower() == <br />          "netdb\\administrator") <br />        { <br />            currentRibbon.TrimById("Ribbon.WebPartPage.Edit"); <br />        } <br />        else if (SPContext.Current.Web.CurrentUser.Name.ToLower() == <br />         "netdb\\adams") <br />        { <br />            currentRibbon.TrimById("Ribbon.WebPartPage.Manage"); <br />        } <br />    } <br />}</p> <p>4. 使用NETDB\Administrator登入<a href="http://sharepoint/default.aspx">http://sharepoint/default.aspx</a>,點選頁面的Ribbon可得到以下的畫面:</p> <p><img title="clip_image004" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image004" src="http://lh3.googleusercontent.com/-eGKddcLL8Bk/VavPaRLKuHI/AAAAAAAA3xI/szDOUkydD0I/clip_image004%25255B9%25255D.png?imgmax=800" width="499" height="215" /></p> <p>5. 使用NETDB\Adams登入<a href="http://sharepoint/default.aspx">http://sharepoint/default.aspx</a>,點選頁面的Ribbon可得到以下的畫面:</p> <p><img title="clip_image005" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image005" src="http://lh3.googleusercontent.com/-r80N7BG4SN4/VavPc5b3sDI/AAAAAAAA3xQ/obq5IwJNW2A/clip_image005%25255B8%25255D.png?imgmax=800" width="524" height="219" /></p> <p>6. 比較第2步驟、第4步驟和第5步驟的畫面,可以得知根據不同的使用者在Ribbon控制項的功能會跟隨著異動,而有不同的顯示。</p> <p>最後,那麼在程式碼中SPRibbon的TrimById(“xxx”)方法中的參數到底要放哪一個值?這個才是重點,其實要放的值為Ribbon上那個控制項的ClientID,這些ID有非常的多,主要的依據要參考以下文件:C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\GLOBAL\XML\CMDUI.XML中的定義,大概的XML結構如下(這邊只擷取部分畫面):</p> <p><img title="clip_image007" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image007" src="http://lh3.googleusercontent.com/-9AbEuRnOyL4/VavPe6eHQXI/AAAAAAAA3xY/C61guYSAANE/clip_image007%25255B9%25255D.jpg?imgmax=800" width="554" height="130" /></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-15428663384571204272015-04-10T01:36:00.000+08:002015-07-20T01:36:33.134+08:00ASP.NET ReportViewer Repeat Column Headers<p>我們在前一篇文章中:<a title="http://ms-net.blogspot.tw/2015/04/aspnet-using-reportviewer-control-to.html" href="http://ms-net.blogspot.tw/2015/04/aspnet-using-reportviewer-control-to.html">http://ms-net.blogspot.tw/2015/04/aspnet-using-reportviewer-control-to.html</a> 有介紹到使用ReportViewer控制項設計報表的基本入門方式,剛好就有朋友另外問我有關頁首和頁尾的使用方式,因此我在這列出其中有兩項的解決方式: <br />1. 報表中加頁首和頁尾 <br />2. 讓報表Table的欄位可以出現在每一頁的最上方</p> <p>請參考以下的做法: <br /><iframe height="315" src="https://www.youtube.com/embed/pndvLcWUQwg" frameborder="0" width="560" allowfullscreen="allowfullscreen"></iframe></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-77128740877358364232015-04-08T23:04:00.000+08:002015-07-20T03:04:39.547+08:00OWASP TOP 10 十大網路應用系統安全弱點 Demo 8<p>OWASP Top 10 主要目的,是將最常見的網路應用系統安全弱點列出,並提供基本的方法保護防止這些弱點,是軟體開發安全計劃最好的開始。</p> <p>以下針對第八點的弱點,做一些簡單的說明和示範:</p> <p>8. Insecure Cryptographic Storage:網路應用程式很少正常使用cryptographic functions來保護資料,使得攻擊者有機可乘並冒用其他使用者身份,進行其他犯罪行為,如盜刷信用卡等。</p> <p><iframe height="315" src="https://www.youtube.com/embed/jtYDXVo87cg" frameborder="0" width="420" allowfullscreen="allowfullscreen"></iframe></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-7419035674796566182015-04-01T07:30:00.000+08:002015-07-20T01:31:22.485+08:00ASP.NET Using ReportViewer Control to Design Report(使用ASP.NET中的ReportViewer控制項設計報表)<p>之前有朋友問我,要在asp.net上使用類似報表的方式在網頁上呈現料資料結果,到底是使用Crystal Report 或是自己寫程式使用GridView比較好? 事實上,端看需求而言,假設要做到像Crystal Report 這樣的功能,那麼自己刻UI畫面一定是比要累的,其實在ASP.NET中有一個ReportViewer控制項還蠻好用的。</p> <p>以下我將ReportViewer控制項有關Print的做法,寫成一個sample code範例,有興趣的朋友可以參考一下範例程式碼檔案,我放在以下網址:</p> <p><a title="https://www.dropbox.com/s/duonhayz0gz6xd9/PrintWeb.7z?dl=0" href="https://www.dropbox.com/s/duonhayz0gz6xd9/PrintWeb.7z?dl=0">https://www.dropbox.com/s/duonhayz0gz6xd9/PrintWeb.7z?dl=0</a></p> <p>另外,我也把簡單的教學開發方式,錄製成步驟放在以下的URL:</p> <p><a href="https://www.youtube.com/watch?v=eMy0IhY_SNM">https://www.youtube.com/watch?v=eMy0IhY_SNM</a></p> <p><iframe height="315" src="https://www.youtube.com/embed/eMy0IhY_SNM" frameborder="0" width="560" allowfullscreen="allowfullscreen"></iframe></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-34507202206539383372015-03-31T03:01:00.000+08:002015-07-20T03:01:57.478+08:00OWASP TOP 10 十大網路應用系統安全弱點 Demo 7<p>OWASP Top 10 主要目的,是將最常見的網路應用系統安全弱點列出,並提供基本的方法保護防止這些弱點,是軟體開發安全計劃最好的開始。</p> <p>以下針對第七點的弱點,做一些簡單的說明和示範,這一個範例是亞當斯的前輩miles所提供的,所使用的方式就是使用c#自己寫HttpRequest去存取指定的網頁,並將利用程式取回的網頁內容HTML進行解譯,並取得一些特殊格式資料:</p> <p><iframe height="315" src="https://www.youtube.com/embed/sgaFD0IkVv0" frameborder="0" width="420" allowfullscreen="allowfullscreen"></iframe></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-49253768850974590982015-03-25T02:56:00.000+08:002015-07-20T02:57:29.551+08:00OWASP TOP 10 十大網路應用系統安全弱點 Demo 6<p>OWASP Top 10 主要目的,是將最常見的網路應用系統安全弱點列出,並提供基本的方法保護防止這些弱點,是軟體開發安全計劃最好的開始。</p> <p>以下針對第六點的弱點,做一些簡單的說明和示範:</p> <p>6. Information Leakage and Improper Error Handling:應用程式可能洩漏關於程式的configuration訊息,程式內部的運轉模式,或者透過多種應用問題違犯隱私。攻擊者利用這個程式弱點侵犯隱私,或者更進一步的攻擊。</p> <p><iframe height="315" src="https://www.youtube.com/embed/t_XS2m14mU4" frameborder="0" width="420" allowfullscreen="allowfullscreen"></iframe></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-51102090440347731772015-03-20T18:34:00.000+08:002015-07-20T02:34:32.341+08:00OWASP TOP 10 十大網路應用系統安全弱點 Demo 5<p>OWASP Top 10 主要目的,是將最常見的網路應用系統安全弱點列出,並提供基本的方法保護防止這些弱點,是軟體開發安全計劃最好的開始。</p> <p>以下針對第五點的弱點,做一些簡單的說明和示範:</p> <p>5. Cross Site Request Forgery(CSRF):CSRF攻擊強迫受害者登入的瀏覽器傳輸pre-authenticated request 給有弱點的網路應用程式,接著強迫受害者瀏覽器執行對攻擊者有好處的的行為。</p> <p><iframe height="315" src="https://www.youtube.com/embed/E6TYok5dr8g" frameborder="0" width="420" allowfullscreen="allowfullscreen"></iframe></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-5068014587435885372015-03-20T01:17:00.000+08:002015-07-20T01:18:59.166+08:00How to Hidden OverwriteFile on DiscussionBoard Upload Page in SharePoint<p>在SharePoint 的討論區清單中,當使用者新增一個討論主題的時候,可以在編輯內容時,使用Ribbon上的插入選項,新增欲上傳的檔案:</p> <p><img title="clip_image002" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image002" src="http://lh3.googleusercontent.com/-U0DQQwp-BcQ/Vavb3-JGj9I/AAAAAAAA3xo/Leq7YanzSQA/clip_image002%25255B6%25255D.jpg?imgmax=800" width="554" height="441" /></p> <p>以下是按下上傳功能時的畫面,但是因為同一個網站中的所有討論區都可以讓使用者上傳文件至指定的清單,這時候會產生一個問題,當不同的討論區上傳檔案時,檔名為相同時就會預設將前一個使用者上傳的文件覆蓋掉。</p> <p><img title="clip_image003" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image003" src="http://lh3.googleusercontent.com/-36pagBrBepo/Vavb5cZQlRI/AAAAAAAA3xw/Roh00TjCHUk/clip_image003%25255B6%25255D.png?imgmax=800" width="399" height="206" /></p> <p>舉個例子:不同的討論區中發表主題時,上傳同一個檔名至:網站資產,此時勾選「複寫現有的檔案」,就會將之前的檔案直接覆寫掉,並且在本文中持續加入新檔案參考:</p> <p><img title="clip_image005" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image005" src="http://lh3.googleusercontent.com/-r9U4QhvdRj8/Vavb7iDcewI/AAAAAAAA3x4/Wgke7XyhxEU/clip_image005%25255B6%25255D.jpg?imgmax=800" width="554" height="440" /></p> <p>那麼如果不勾選「複寫現有的檔案」,就會有以下的訊息提示使用者。</p> <p><img title="clip_image006" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image006" src="http://lh3.googleusercontent.com/-JXY6nD482iE/Vavb9EsPKBI/AAAAAAAA3yA/7ayieWjLOJo/clip_image006%25255B6%25255D.png?imgmax=800" width="400" height="209" /></p> <p>有些情境因為考量到不讓使用者可以自行勾選「複寫現有的檔案」,因此必須將「複寫現有的檔案」選項設定為不顯示,並且預設是不勾選,該如何完成此需求呢? 執行步驟如下:</p> <p>1. 找到C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS下的RteUploadDialog.aspx</p> <p>2. 進入編輯模式,找到</p> <p><asp:CheckBox id="OverwriteFile" Checked="true" Text="<%$Resources:wss,upload_document_overwrite_file%>" runat="server" /></p> <p>3. 修改為以下的設定:</p> <p><asp:CheckBox id="OverwriteFile"<b> Checked="<font color="#ff0000">false</font>" Visible="<font color="#ff0000">false</font>"</b> Text="<%$Resources:wss,upload_document_overwrite_file%>" runat="server" /></p> <p>4. 重新新增討論主題並上傳文件,可以檢視畫面已被修改:</p> <p><img title="clip_image003[7]" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image003[7]" src="http://lh3.googleusercontent.com/-dooMF80DJx0/Vavb-jVMx0I/AAAAAAAA3yI/L6W8ZJwH8qQ/clip_image003%25255B7%25255D%25255B5%25255D.png?imgmax=800" width="400" height="185" /></p> <p>5. 針對相同的清單上傳已存在名稱的文件時,將預設會判斷已存在,不得重複上傳,如下圖所示:</p> <p><img title="clip_image004" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image004" src="http://lh3.googleusercontent.com/-kZJH9jr6iqQ/VavcAWBvasI/AAAAAAAA3yQ/vQ2fdwUtCOM/clip_image004%25255B6%25255D.png?imgmax=800" width="400" height="188" /></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-72407195881228544302015-02-27T22:31:00.000+08:002015-07-20T02:33:05.052+08:00OWASP TOP 10 十大網路應用系統安全弱點 Demo 4<p>OWASP Top 10 主要目的,是將最常見的網路應用系統安全弱點列出,並提供基本的方法保護防止這些弱點,是軟體開發安全計劃最好的開始。</p> <p>以下針對第四點的弱點,做一些簡單的說明和示範:</p> <p>4. Insecure Direct Object Reference:Direct object reference發生的原因是因為開發者暴露了reference to an internal implementation object,像是檔案、檔案夾、或資料庫的record,或是key,來作為URL或是Form的參數。攻擊者可藉由操作這些references擅自進入其他objects中。</p> <p><iframe height="315" src="https://www.youtube.com/embed/R31wSD7QWAE" frameborder="0" width="420" allowfullscreen="allowfullscreen"></iframe></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-57539405763982147062015-02-20T02:30:00.000+08:002015-07-20T02:31:09.411+08:00OWASP TOP 10 十大網路應用系統安全弱點 Demo 3<p>OWASP Top 10 主要目的,是將最常見的網路應用系統安全弱點列出,並提供基本的方法保護防止這些弱點,是軟體開發安全計劃最好的開始。</p> <p>以下針對各種不同的弱點,做一些簡單的說明和示範:</p> <p>3. Insecure Remote File Include:有弱點的程式碼讓攻擊者可附加惡意程式及資料,甚至導致毀滅性的攻擊,例如整個伺服器被入侵。 <br /><iframe height="315" src="https://www.youtube.com/embed/sbdALhnkFK4" frameborder="0" width="420" allowfullscreen="allowfullscreen"></iframe></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-66334729381926826292015-02-13T02:29:00.000+08:002015-07-20T02:29:30.196+08:00OWASP TOP 10 十大網路應用系統安全弱點 Demo 2<p>OWASP Top 10 主要目的,是將最常見的網路應用系統安全弱點列出,並提供基本的方法保護防止這些弱點,是軟體開發安全計劃最好的開始。</p> <p>以下針對各種不同的弱點,做一些簡單的說明和示範:</p> <p>2. Injection Flaws :在網路應用程式,SQL Injection裡很常見。Injection之所以會發生,是因為使用者提供的資料傳輸到一個interpreter,此被當成指令(Command)或是查詢(Query)。攻擊者就能用惡意的資料欺騙interpreter,而達到執行指令或是竄改資料的目的。</p> <p><iframe height="315" src="https://www.youtube.com/embed/hq6kixeBh0Q" frameborder="0" width="420" allowfullscreen="allowfullscreen"></iframe></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-35284676864768620432015-02-06T02:27:00.000+08:002015-07-20T02:27:36.500+08:00OWASP TOP 10 十大網路應用系統安全弱點 Demo 1<p>OWASP Top 10 主要目的,是將最常見的網路應用系統安全弱點列出,並提供基本的方法保護防止這些弱點,是軟體開發安全計劃最好的開始。</p> <p>以下針對各種不同的弱點,做一些簡單的說明和示範:</p> <p>1. Cross Site Scripting(XSS):當應用程式未將使用者提供的資料先審核或進行內容編碼,就直接將資料傳輸到網路瀏覽器,即可能發生XSS問題。XSS能讓攻擊者直接在受害者的網路瀏覽器上執行Script,攻擊者便可以hijack user sessions、或竄改網站內容等。</p> <p><iframe height="315" src="https://www.youtube.com/embed/7AlvXd1OfkQ" frameborder="0" width="420" allowfullscreen="allowfullscreen"></iframe></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com1tag:blogger.com,1999:blog-8006724255930921548.post-9968286476387359912015-01-23T19:10:00.000+08:002015-07-16T19:14:31.883+08:00.NET Call SAP/RFC by Visual Basic & VS.NET(sample code)<p>多年前寫了一篇文章: <a href="http://ms-net.blogspot.tw/2010/02/net-call-saprfc-by-visual-basic-vs2010.html">.NET Call SAP/RFC by Visual Basic & VS2010</a> ,使用.net code去跟sap連結</p> <p>因為當初寫完並沒有提供sample code,因此在留言的地方有很多朋友可能都會遇到一些問題,剛好最近在整理NB裡面的資料,因此就把當初所寫的範例程式碼分享出來,希望對需要的朋友有所幫助,當初是使用VS2010開發的,但目前來說應該是沒啥影響!! </p> <p>以下是sample code download的超連結,分別有c#版和vb版! </p> <p><a title="https://www.dropbox.com/s/jwe4oeue6gd8x8m/DemoSAP.7z?dl=0" href="https://www.dropbox.com/s/jwe4oeue6gd8x8m/DemoSAP.7z?dl=0">https://www.dropbox.com/s/jwe4oeue6gd8x8m/DemoSAP.7z?dl=0</a></p> <p>檔案解壓縮密碼是:sap</p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-39768997768000537332014-10-22T01:41:00.001+08:002014-10-22T01:41:26.538+08:00有關Sandboxed Solution在單機開發環境上的錯誤-An unknown exception occurred while executing a sandboxed code solution request in the worker process.\r\n|0<p>先說明一下,遇到這問題的情況,因為最近在準備新的課程教材,因此安裝設定一個SharePoint 2013的開發環境,而這個環境是所謂的All-in-One開發環境,也就是:Windows 2012 + DC +  IIS +SharePoint 2013 + SQL Server 2012 + VS2012… 全部都安裝在同一個VM上。</p> <p>理論上來說這些不同的Service在正式SharePoint環境上其實都是分開機器安裝的 ,因此,在測試Sandboxed Solution的時候,單純的新增一個WebPart,然後選擇使用Sandboxed Solution部署,部署完成之後,當此WebPart要加入至網頁中,就出現了以下的錯誤訊息:An unknown exception occurred while executing a sandboxed code solution request in the worker process.\r\n|0</p> <p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.ggpht.com/-MZR0QJJ3z9o/VEaaoqeynMI/AAAAAAAA0Bk/fL5kIGma-Oo/image%25255B26%25255D.png?imgmax=800" width="469" height="164" /></p> <p>針對這個問題,查了ULS LOG,也上網找了一些相關的討論,目前得到的結果是:在Windows 2012環境上假設將DC 和 SharePoint 等服務全部裝在一起的話,Sandboxed Solution就不Support.</p> <p>不過,高手還是很多的,以下有找到一篇文章有暫時的解決方案,原文在此:<a title="http://spvee.wordpress.com/2013/08/14/sandboxed-solution-on-sharepoint-2013-with-domain-controller-worked/" href="http://spvee.wordpress.com/2013/08/14/sandboxed-solution-on-sharepoint-2013-with-domain-controller-worked/">http://spvee.wordpress.com/2013/08/14/sandboxed-solution-on-sharepoint-2013-with-domain-controller-worked/</a> ,<font color="#ff0000">重點:設定Sandboxed Code Service Log 啟用Verbose. </font>不過印象中假設OS是Windows 2008 R2就沒有這問題。對我來說,因為這種All-In-One的環境本來就是開發測試用的,不大有機會拿來當客戶的正式機使用,因此以下的解決方式就可以解決使用Sandboxed Solution的專案了!!!!</p> <p>設定步驟如下:</p> <p>1. 首先至管理中心 –> Monitoring –> Configure diagnostic logging</p> <p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.ggpht.com/-fmzHJFDto74/VEaaqyKpNkI/AAAAAAAA0Bs/GsZ1dS5C3Tk/image%25255B13%25255D.png?imgmax=800" width="686" height="265" /></p> <p>2. 找到SharePoint Foundation下的Sandboxed Code Service,勾選Sandboxed Code Service之後,畫面移至下方,然後Least critical event to report to the trace log這個選項,選擇:Verbose,按下OK!!</p> <p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh6.ggpht.com/-KfIPtfO1iFI/VEaasMQzYzI/AAAAAAAA0B0/s98yktjorc8/image%25255B24%25255D.png?imgmax=800" width="287" height="106" /></p> <p>3. Sandboxed Code Service 其 Trace Level設定為Verbose.</p> <p><a href="http://lh6.ggpht.com/-6hf8JNIqjgU/VEaatcky8QI/AAAAAAAA0B8/7MbiWkSm_zc/s1600-h/image%25255B29%25255D.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.ggpht.com/-hvhDRZ1GSxA/VEaaunzOATI/AAAAAAAA0CE/cyoxrXMXTgM/image_thumb%25255B11%25255D.png?imgmax=800" width="599" height="30" /></a></p> <p>4. 回到網頁,將Sandboxed 的WebPaer重新加入網頁中,成功了!!</p> <p><a href="http://lh5.ggpht.com/-M11h64MMqGc/VEaavxVLe_I/AAAAAAAA0CM/A4H1QO7Etps/s1600-h/image%25255B34%25255D.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh4.ggpht.com/-VMLVtGgjcWI/VEaaxFhdb8I/AAAAAAAA0CU/hE7PJwdJKRs/image_thumb%25255B14%25255D.png?imgmax=800" width="309" height="83" /></a></p> <p>以上唯一要擔心的是,因為log是設定為Verbose,因此所有Sandboxed 的全部資訊都會記錄至Log中,對硬碟的空間耗用會比較大,因此Log的使用就要稍微小心一些唷!</p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-68598767003235931722014-09-28T15:11:00.001+08:002014-09-28T15:11:07.867+08:00SharePoint 2013 JavaScript Runtime Error – RegisterSod is undefined<p>開發這麼久的SharePoint 昨天第一次遇到這個錯誤訊息:SharePoint 2013 JavaScript Runtime Error – 'RegisterSod' is undefined,錯誤的畫面如下:</p> <p><a href="http://lh4.ggpht.com/-iapiQiVvYlc/VCe0W0BVHoI/AAAAAAAAznE/zBHXz7TZZ34/s1600-h/image%25255B36%25255D.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh6.ggpht.com/-KAZErLFB8mE/VCe0YCgeC3I/AAAAAAAAznM/nzjHq-_rjlc/image_thumb%25255B26%25255D.png?imgmax=800" width="557" height="316" /></a></p> <p>先來說說我的開發步驟,其實步驟是很單純的:</p> <p>1. 使用VS2012建立一個App的專案,然後設定欲部署的Site Url,如下:<a href="http://xxxxxx/sites/appHost">http://xxxxxx/sites/appHost</a></p> <p><a href="http://lh5.ggpht.com/-1i0Gq-G1WkA/VCe0ZHYtOFI/AAAAAAAAznU/I2nhaxubVEo/s1600-h/image%25255B39%25255D.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh6.ggpht.com/-VJS1PQfP4xo/VCe0aCcub3I/AAAAAAAAznc/SdH88-2c89g/image_thumb%25255B29%25255D.png?imgmax=800" width="371" height="250" /></a></p> <p>2. 然後…就直接F5部署啦! 這時就出現了以上的錯誤訊息:JavaScript Runtime Error – RegisterSod is undefined</p> <p>那麼問題到底在哪? <font color="#ff0000">答案就</font><font color="#ff0000">是SharePoint 2013上Site Collection可能尚未設定 “根路徑Site Collection (Root Site Collection)”。</font></p> <font color="#ff0000"></font> <p>以下是我目前的環境上的Site Collection,我在建置Site Collection時是直接使用sites路徑建立的,因此並未建立所謂的根路徑Site Collection:</p> <p><a href="http://lh3.ggpht.com/-g-8bhGI5ERE/VCe0bAIfHCI/AAAAAAAAznk/G4g1o4TvMp8/s1600-h/image%25255B43%25255D.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh3.ggpht.com/-6W7UM9oP5-A/VCe0c_tIz0I/AAAAAAAAzns/acjrjBdsj2w/image_thumb%25255B33%25255D.png?imgmax=800" width="372" height="253" /></a></p> <p>在SharePoint 2010以往的開發部署過程中,並不需要去考量Site Collection的設定以及建置關聯,因為在SharePoint 2010是開發Server OM,因此直接部署就可以WORK! 但是在SharePoint 2013 App卻不行,SharePoint 2013 App 會用到大量的Client Script,因此在執行時會預先載入一堆的Client Script,而此時路徑相對的就很重要。</p> <p>因此<font color="#ff0000">解決的方式就是先直接建立一個根路徑Site Collection,以下畫面中的 / 就是建立根路徑的Site Collection</font></p> <p><a href="http://lh4.ggpht.com/-YW_I8zAW2v0/VCe0eAEo5DI/AAAAAAAAzn0/3qaAgNzXyQ0/s1600-h/image%25255B47%25255D.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh4.ggpht.com/-I3siD3kEfJw/VCe0fAcMN0I/AAAAAAAAzn8/77W1ytd6tic/image_thumb%25255B37%25255D.png?imgmax=800" width="376" height="273" /></a></p> <p>然後我們在部署一次APP看看!!成功了!!</p> <p><a href="http://lh6.ggpht.com/-hQR8VgYtJCw/VCe0hFLCLEI/AAAAAAAAzoE/004FEsERVQg/s1600-h/image%25255B50%25255D.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://lh5.ggpht.com/-TbrRd6Iic4w/VCe0iWFM-BI/AAAAAAAAzoM/VuETXQ2Av5U/image_thumb%25255B40%25255D.png?imgmax=800" width="368" height="207" /></a></p> <p>其實Google了一下,發現有很多人都遇到相同的問題! MSDN論壇上也有很多人在討論,以下有相關問題說明: <br /><a title="http://algrandi.azurewebsites.net/index.php/sharepoint-2013-error-registersod-is-undefined/" href="http://algrandi.azurewebsites.net/index.php/sharepoint-2013-error-registersod-is-undefined/">http://algrandi.azurewebsites.net/index.php/sharepoint-2013-error-registersod-is-undefined/</a></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0tag:blogger.com,1999:blog-8006724255930921548.post-90716019511557428582013-11-11T14:38:00.000+08:002014-03-31T14:39:56.990+08:00Custom Access SharePoint User Profile Service Application (客製化存取ShaePoint的User Profile Service Application)<p>SharePoint有一個User Profile Service Application服務,用來識別帳戶的相關資訊,當安裝SharePoint時,假設帳戶是來自AD的話,那麼也可以將AD中所設定的帳戶資料,直接同步至SharePoint 的User Profile Service Application中,後續使用者就可以直接在SharePoint中編輯這些資訊。</p> <p>那麼,假設我們想要設計一些維護介面,或是客製化應用程式去存取User Profile Service Application的話,該怎麼做了? 以下步驟說明開發方式:</p> <p>1. 首先我們先建立一個SharePoint專案,接著在此專案中加入對應的dll組件</p> <p><img title="1" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="1" src="http://lh5.ggpht.com/-_KQuryoQya0/UzkNk9nIbrI/AAAAAAAAzCw/pCQtRXcNPS0/1%25255B4%25255D.png?imgmax=800" width="468" height="383" /></p> <p>2. 新增一個ApplicationPage.aspx用來測試功能,新加入控制項:一個按鈕;一個ListBox</p> <p><img title="3" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="3" src="http://lh4.ggpht.com/-eAgXs6LOJHw/UzkNmtKou-I/AAAAAAAAzC4/K8wf0wsnlsg/3%25255B5%25255D.png?imgmax=800" width="597" height="84" /></p> <p>3. 切換至.cs中,先匯入欲使用的Namespace</p> <p><img title="2" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="2" src="http://lh6.ggpht.com/-QUsN0XhAzxs/UzkNoCa8DwI/AAAAAAAAzDA/IVvHKdF3Yoo/2%25255B8%25255D.png?imgmax=800" width="306" height="65" /></p> <p>4. 在Page_Load中使用UserProfileManager物件載入相對應的Profile,並且我們取出AccountName、WorkEMail、PersonalSpace等屬性資料呈現:</p> <p><img title="4" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="4" src="http://lh3.ggpht.com/-d3tWcezas2E/UzkNpT-oomI/AAAAAAAAzDI/TGWTt0MXkt4/4%25255B5%25255D.png?imgmax=800" width="537" height="389" /></p> <p>5. 先看一下執行的結果,如下圖所示,在ListBox中會寫出目前在網站中有使用Profile的資料:</p> <p><img title="7" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="7" src="http://lh5.ggpht.com/-Dj8DjgASHcA/UzkNrJBTQjI/AAAAAAAAzDQ/jPZXghIBZ5I/7%25255B4%25255D.png?imgmax=800" width="446" height="91" /></p> <p>6. 取出Profile資料後,接著我們亦可撰寫更新Profile的程式碼,在按鈕的Click事件中,撰寫如下的程式碼,透過Web.CurrentUser.LoginName取得目前登入的使用者帳號,然後當作參數丟給UserProfileManager的GetUserProfile方法,即可取得目前登入者的Profile物件,最後更新Profile時記得要呼叫Commit方法:</p> <p><img title="5" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="5" src="http://lh4.ggpht.com/-7ipRm4Hkv_0/UzkNs5bfK9I/AAAAAAAAzDY/Vk5EONVHzUA/5%25255B5%25255D.png?imgmax=800" width="479" height="228" /></p> <p>7. 執行結果,使用LauraG登入,且按下按鈕後,EMail就會被更新了</p> <p><img title="7" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="7" src="http://lh3.ggpht.com/-BmuICVL4rTY/UzkNu--GGnI/AAAAAAAAzDg/Rf4cnK8ucYE/7%25255B9%25255D.png?imgmax=800" width="446" height="91" /></p> 亞當斯(Adams)http://www.blogger.com/profile/09679007289731771586noreply@blogger.com0