the following module was built either with optimizations enabled or without debug information
solution:
I have also faced the same problem on migrating the application .net 1.x to 2.0 and i solved by disabling the "Warn if no user code on launch" under the debugging option in the tools menu.
Tools --> Options --> Debugging --> General --> Enable Just my code (Managed only) --> un check "Warn if no user code on launch"
Release build模式无法调试,会直接run 过
Powershell使用dll
password="password"securePassword = ConvertTo-SecureString password−AsPlainText−Forcedomain="domain"
userName="user"credential = new-object Management.Automation.PSCredential((domain+"\"+userName),securePassword)computerName = "sptws-sut02"
mainUrl="http://"+computerName
siteName="test"path="C:\Users\pettest\Desktop"
webName="HAHAHA"attachmentName="testAttachmentName2"
attachmentName=attachmentName + ".txt"
ret=invoke−command−computercomputerName -Credential credential -scriptblock{ param( [string]siteName,
[string]webName,[string]path,
[string]attachmentName,[string]mainUrl
)
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | out-null
spSites=new−objectMicrosoft.SharePoint.SPSite(mainUrl)
spWeb=spSites.openweb(siteName+"/"+webName)
attachmentUrl=path + "\" + attachmentNamefStream = [System.IO.File]::OpenRead(attachmentUrl)byteArray = new-object byte[] fStream.LengthfStream.Read(byteArray,0,[int]fStream.Length);
fStream.close()spWeb.Folders["Shared Documents"].Files.Add(attachmentName,byteArray)
}-argumentlist siteName,webName, path,attachmentName,mainUrlPowershell使用sharepoint自带的powershellret = invoke-command -computer computerName−Credentialcredential -scriptblock{
param(
)
ver=host | select version
if (ver.Version.Major−gt1)$Host.Runspace.ThreadOptions="ReuseThread"Add−PsSnapinMicrosoft.SharePoint.PowerShellSet−locationhome
application=Get−SPServiceApplication−name"BusinessDataConnectivity"guid=application.IDwrite−hostguid
return guidPublish−SPServiceApplicationguid
}
Sharepoint的Powershell
罗列一些命令:
Get-SPDatabase
Database:Microsoft.Office.Server.Administration.ProfileDatabase
DataConnectionFile:Microsoft.Office.InfoPath.Server.Administration.DataConnectionFile
Get-SPIisWebServiceApplicationPool
Get-SPServiceApplication
Stop-SPServiceInstance –Identity id–comfirm:false
远程调用Powershell前,client和server要执行:
Enable-PSRemoting
Set-executionPolicy unrestricted/remotesigned
如果client端是x64,则务必在powerehll-x86和-x64上都要执行
本文转自轩脉刃博客园博客,原文链接:http://www.cnblogs.com/yjf512/archive/2010/10/29/1864413.html,如需转载请自行联系原作者