ค้นหาเว็บไซต์

แก้ไขข้อผิดพลาด "MissingAssembly" ของ Test-SPContentDatabase ในการโยกย้าย SharePoint 2013


ปัญหา:
ในระหว่างการโยกย้าย SharePoint 2013 เรารัน Test-SPContentDatabase cmdlet, และรายงานผลลัพธ์มีข้อผิดพลาด MissingAssembly หลายรายการ!

Category : MissingAssembly
ข้อผิดพลาด : True
UpgradeBlocking : False
ข้อความ : Assembly [DealEventEventhandler, Version=1.2.6.0, Culture=neutral, PublicKeyToken=b4122bae67581526] มีการอ้างอิงในฐานข้อมูล [wss_content] แต่ไม่ได้ติดตั้งในฟาร์มปัจจุบัน โปรดติดตั้งฟีเจอร์/โซลูชันใดๆ ที่มีแอสเซมบลีนี้
วิธีแก้ไข : มีการอ้างอิงแอสเซมบลีอย่างน้อยหนึ่งรายการในฐานข้อมูล [wss_content] แต่ไม่ได้ติดตั้งในฟาร์มปัจจุบัน โปรดติดตั้งคุณลักษณะหรือโซลูชันที่มีส่วนประกอบเหล่านี้

สาเหตุหลัก:
โดยปกติแล้ว ข้อผิดพลาด MissingAssembly เกิดขึ้นกับตัวรับเหตุการณ์ที่ไม่ได้ติดตั้งและปรับใช้กับฟาร์ม และยังคงมีการอ้างอิงในรายการ SharePoint หรือไลบรารี!

วิธีแก้ปัญหา:

ติดตั้งฟีเจอร์/โซลูชันที่ขาดหายไปซึ่งประกอบด้วยแอสเซมบลีที่ขาดหายไปใน SharePoint Farm ของคุณ! ง่ายใช่มั้ย? แต่เดี๋ยวก่อน คุณอาจไม่อยู่ในฐานะที่จะทำเช่นนี้ได้เสมอไป และคุณอาจดำเนินการค้นหาและลบแอสเซมบลีที่ขาดหายไปจาก SharePoint ในบางครั้ง

ค้นหาตำแหน่งทั้งหมดที่มีการอ้างอิงแอสเซมบลีที่ขาดหายไปและลบออกโดยใช้ PowerShell:

ลองใช้ PowerShell เพื่อค้นหาสถานที่ทั้งหมดที่มีการใช้ชุดประกอบเฉพาะและนำออก แอสเซมบลีอาจเป็นส่วนหนึ่งของตัวรับเหตุการณ์ SharePoint ตั้งค่าพารามิเตอร์การกำหนดค่าในสคริปต์จากผลลัพธ์ Test-SPContentDatabase


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

Function Run-SQLScript($SQLServer, $SQLDatabase, $SQLQuery)
{
    $ConnectionString = "Server =" + $SQLServer + "; Database =" + $SQLDatabase + "; Integrated Security = True"
    $Connection = new-object system.data.SqlClient.SQLConnection($ConnectionString)
    $Command = new-object system.data.sqlclient.sqlcommand($SQLQuery,$Connection)
    $Connection.Open()
    $Adapter = New-Object System.Data.sqlclient.sqlDataAdapter $Command
    $Dataset = New-Object System.Data.DataSet
    $Adapter.Fill($Dataset) 
    $Connection.Close()
    $Dataset.Tables[0]
}

#Define configuration parameters
$Server="Abj-SQL-001"
$Database="WSS_Content_KM"
$AssemblyInfo="DealEventHandler, Version=1.2.6.0, Culture=neutral, PublicKeyToken=d256f51c842671b3"           

#Query SQL Server content Database to get information about the MissingAssembly
$Query = "SELECT distinct Id, SiteId, WebId, HostId, HostType from EventReceivers where Assembly = '"+$AssemblyInfo+"'"
$QueryResults = Run-SQLScript -SQLServer $Server -SQLDatabase $Database -SQLQuery $Query # | select Id, Name, SiteId, WebId, HostId, HostType

#Iterate through results
foreach ($Result in $QueryResults)
{
    if($Result.id -ne $Null)
    {
        #Get the location where the event receiver is referred
        if ($Result.HostType -eq 0) #Site Event Receiver
        {
            $Site = Get-SPSite -Limit all | where {$_.Id -eq $Result.SiteId}
            $EventReceiver = $Site.EventReceivers | where {$_.Id -eq $Result.Id}
            #To Delete the Event Receiver
            #$EventReceiver.Delete()
            write-host "Site Event Receivers Found at $($Site.URL)" -foregroundcolor green
        }
        if ($Result.HostType -eq 1) #Web Event Receiver
        {
            $Site = Get-SPSite -Limit all | where {$_.Id -eq $Result.SiteId}
            $Web = $Site | Get-SPWeb -Limit all | where { $_.Id -eq $Result.WebId }
            $EventReceiver = $Web.EventReceivers | where {$_.Id -eq $Result.Id}
            #To Delete the Event Receiver
            #$EventReceiver.Delete()
            write-host "Web Event Receivers Found at $($web.URL)" -foregroundcolor green
        }
        if ($Result.HostType -eq 2) #List Event Receiver
        {
            $Site = Get-SPSite -Limit all | where {$_.Id -eq $Result.SiteId}
            $Web = $Site | Get-SPWeb -Limit all | where { $_.Id -eq $Result.WebId }
            $List = $web.Lists | where {$_.Id -eq $Result.HostId}
            $EventReceiver = $List.EventReceivers | where {$_.Id -eq $Result.Id}
            #To Delete the Event Receiver
            #$EventReceiver.Delete()
            write-host "List Event Receivers Found at $($web.url)/$($List.RootFolder.Url)" -foregroundcolor green
        }
    }
} 

สคริปต์นี้ค้นหาตำแหน่งทั้งหมดที่มีการอ้างอิงแอสเซมบลีเฉพาะ ยกเลิกหมายเหตุบรรทัด EventReceiver.delete() เพื่อลบตัวรับเหตุการณ์

นี่คือโพสต์อื่นเพื่อแก้ไขข้อผิดพลาดที่ขาดหายไปของแอสเซมบลีใน SharePoint 2010 ถึงการโยกย้าย SharePoint 2013 แก้ไขปัญหา "ตัวรับเหตุการณ์ที่ขาดหายไป" ในการโยกย้าย SharePoint

บทความที่เกี่ยวข้อง