Follow steps to create Create dll file for the class using Visual Studio 2010 in SharePoint 2010
1. In Visual Studio click File, click on New Project and select .NET Framework 3.5 as the target framework, select SharePoint 2010 under the installed template, select the Empty SharePoint Project and give the project name SharePointDllFileExample and then click OK. See in fig
2. Give the SharePoint URL and port and choose to Deploy as a farm solution and then click on Finish. See in fig
3. Now right click on solution explorer =>add =>New Item. See in fig
4. Now Select Class under code of Visual c# and give the class name classTobecalledUsingDll.cs and click OK. See in fig
5. Now write the following code in this class. See in fig
6. Now build the project from the solution explorer. See in
7. Now you can see you classTobecalledUsingDll.dll into Projects\SharePointDllfileExample\SharePointDllfileExample\bin\Debug\ directory
8. Now add your assembly to global assembly cache (GAC). Either you can drag from debug (C:\Users\cjuser\Documents\VisualStudio2010\Projects\SharePointDllfileExample\SharePointDllfileExample\bin\Debug\) into C:\Windows\assembly directory. Otherwise, you can use command line utility.
9. Now you have to register your assembly into the project where you want to use. In my case, I am using it in a master page. Add below code to the top of the page.
<%@ Assembly Name=”#strong name#” %>
<%@ Import Namespace=”#assembly name# “%>
10. Replace #strong name# with the strong name of the class and “#assembly name# with the name of an assembly of the class. To find strong name follow this link.
11. Otherwise go to C:\Windows\assembly and select classTobecalledUsingDll.dll file right click on it and select properties. See in fig
12. You will get assemblyname, Version ,Culture and publickeyToken In this case it will look like this
JOIN a FREE SharePoint Video Course (3 Part Video Series)
About Navneet Singh
I am Navneet Singh, Working at C3it software solutions pvt. ltd. in Pune. My core skills are SharePoint 2013, Office 365, SharePoint 2010, SharePoint Designer, SharePoint Designer Workflow, Nintex Workflow, Infopath, Webpart, CSOM/SSOM, Power-shell, C#, ASP.NET and SQL Server.
Your FREESharePoint Online Ebook is on its way to your Email Inbox. **************** You will get notification on FREE SharePoint online training, SharePoint webinars, Video Tutorial & also latest FREE PDF tutorials