I have created a sp 2013 webpart. Inside this webpart I am using the RazorEngine.dll. It is included by NuGet and the solution builds. when I deploy and add the webpart to the page I got this error:

System.IO.FileNotFoundException: Could not load file or assembly 'RazorEngine, Version=, Culture=neutral, PublicKeyToken=9ee697374c7e744a' or one of its dependencies. 
The system cannot find the file specified. File name: 'RazorEngine, Version=, Culture=neutral, PublicKeyToken=9ee697374c7e744a' 
at MyCompany.SharePoint.WebParts.FormWebPart.Razor.RazorParser.GetRazorOutput(String template) 
at MyCompany.SharePoint.WebParts.FormWebPart.CONTROLTEMPLATES.FormUserControl.GetRazorOutput(String template, NameValueCollection data) 
at MyCompany.SharePoint.WebParts.FormWebPart.CONTROLTEMPLATES.FormUserControl.OnPreRender(EventArgs e) 

When I go to the assembly folder (C:\Windows\Microsoft.NET\assembly\GAC_MSIL) I do not see this dll. Why it is not deployed with my solution? I deployed the solution by VS.

enter image description here

enter image description here


This is because it is not deployed by your solution, only referenced!

In Visual Studio, double click the Package file and choose the "Advanced" tab.

Then on that tab add a reference to the file from where nuget downloads it in your project folder. This way it will be deployed to GAC on installation of your wsp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.