In this blog, I will explain how you can refer external dll in your SharePoint solution to make it work wherever this dll is not there in the Global Assembly Cache. So the solution itself must contain the dll. To add dll into your SharePoint solution below are the steps:
- Reference the dll in the Solution references first.
- Now add the dll into your solution by selecting the dll. Once you add it, it will appear in the References list. But it will not be added to the package of Solution, which we have to manually do that.
- Open package file
- Open Advanced Click Add > Add Existing Assembly
- Select dll source path. Now click OK. Make sure Deployment Target is
Once you are done with above steps. Now verify that WSP is containing that dll.
In my case I have renamed it from EmbedExternalDLLs.wsp file to EmbedExternalDLLs.cab and extract it to the folder. In that folder you will find that added dll.
In one of my project, I had requirement to migrate record center site collection to the new server but in that requirement I had to create only new site collection with existing web application and different database.
So to achieve this, below is the detailed snippet of PowerShell script.
First of all I took backup of the source site collection:
Backup-SPSite –Identity http://sharepointolddev –LiteralPath "C:\Backup\olddev.bak"
Now to restore above backup into new site collection I needed to create separate content database. Below is the script to create new content database under a web application.
New-SPContentDatabase -Name "WSS_Content_DBNew" -DatabaseServer "MYDBNAME" -WebApplication http://sharepointdev/
Once that Database is created I created empty site collection with record center site template. Below is the snippet to create new site collection with created content database.
$site = "http://sharepointdev/sites/newdev"
$dbname = Get-SPContentDatabase "WSS_Content_DBNew"
$ownerAlias = "sp\prathod";
New-SPSite -URL $site -OwnerAlias $ownerAlias -SecondaryOwnerAlias $ownerAlias -ContentDatabase $dbname -Template "OFFILE#1"
Once site collection is created I simply restored existing site collection backup with below snippet:
Restore-SPSite –Force –Identity http://sharepointdev –LiteralPath "C:\Backup\olddev.bak"
That’s it, site collection is restored with new content database in existing web application.