1

Background:

I have developed a Farm solution webpart for SharePoint 2013 Enterprise more than a year ago. This project uses two DLL which are:

  • sample_1.dll
  • sample_2.dll

The whole solution consist:

  • (2) Class libraries build in Framework 4.0 (for use the SharePoint Dll's reference described below).
  • SharePoint 2013 visual webpart.

These DLL's uses the following SharePoint DLL reference:

  • Microsoft.SharePoint.dll: "runtime version used is v4.0.30319 / version 15.0.0.0".

These DLL's are registered in the PC that I used for develop this project and the project itself was implemented in a test site.

Due to certain limitations that I'm afraid I can't explain in detail, the Application pool and the site "in IIS" was shutdown after delivery this project to the client (mostly for saving "RAM")...

Now, the site and application pool has been turned on again. To my surprise, the site hasn't the webpart anymore and I had to start the implementation again.

Problem:

When I tried to add the webpart in a test page in the test site, I get this error:

Error after select a custom webpart.

Checking the logs, I found this detailed error:

Getting Error Message for Exception Microsoft.SharePoint.WebPartPages.WebPartPageUserException: $Resources:core,ImportErrorMessage; ---> System.Reflection.TargetInvocationException: An exception occurred in the target of an invocation ---> System.IO.FileNotFoundException: Could not load file or assembly 'sample_1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f1cd0442b97c7541' or one of its dependencies. The system cannot find the file specified.

The web.config file has added the entries in the entries in SafeControls tag.

I have used gacutil.exe for register those DLL's, but, they aren't registered in the following location:

  1. C\Windows\assembly

Instead, they're registered in

  1. C:\Windows\Microsoft.NET\assembly\GAC_MSIL\sample_1

Which, according to this link I used the 4.0 version of gacutil.exe I should use the 2.0 version.

I really don't understand why these DLL's need to be in the first location.

5
  • The links explains why we have 2 GAC ? The webpart might be built using 3.5 .
    – Arvi
    Jul 28, 2016 at 0:41
  • @MpArvind, the dll was build in framework 4.0, I did read the link you provided. The strange thing is, this project has the references in the GAC and all was working as expected. Jul 28, 2016 at 13:16
  • Are you 100% putting (manually, i.e. for tests while you try to troubleshoot the problem) the DLL into C:\Windows\assembly immediately solves the problem? Is this a pure SP2013 site (not migrated from SP2010)? Is your Web part built specifically for SP2013 (with VS20102 or above)?
    – Evariste
    Jul 28, 2016 at 14:03
  • Putting the dll "i.e drag and drop" didn't work and according to this link, that wont work. It is SP2013 site using Visual Studio 2012 ultimate. Jul 28, 2016 at 14:14

3 Answers 3

1
+50

should be simple enough, could be the issue that the project when deploying is ignoring the dll files. you could set the DLL's to local within VS that adds it to the bin folder or the correct method is that its not stated within the package.package which is simple enough:

1) Open Package.package in visual studios.

2) Click Advanced in bottom area (current view is Design).

3) Click Add and chose the two assemblies you wanted to add/update.

4) Within the dialog select dll file as you need to navigate to where the dll is located, add safe control for both and class resources entries if needed. once complete click the ok button and build then deploy.

now when you deploy to live or any other the two dll's are always deployed every time!


also like to note that "C:\Windows\assembly" was pre sharepoint 2013 for .net 3.5 and lower.

in sharepoint 2013+ it uses the new location as you referenced. its slightly different. If you were to build .net 4.0 project it will deploy it to specific folders related the the .net version.

if the two DLL's are 3.5 and lower then they need to be in the older assembly folder "C:\Windows\assembly" using the gacutil.exe.

If the two dlls are 4.0+ then use the newer gacutil.exe located at "\Program Files\Microsoft SDKs\Windows\v7.1\Bin"

in your case you shouldnt need to do above if its properly included in the project, when you deploy it should add them correctly.

also make sure the safe control is correct, check that the key in gac is the same in the safe control.

2
  • Thank you. A few days back, I tried these answers and it worked wonders. Your answer expands the workaround about this problem. Aug 2, 2016 at 13:29
  • no problem happy to help
    – Ali Jafer
    Aug 3, 2016 at 6:39
0

First check the solution (wsp) is still available on the Farm. If yes then do a deployment and that can fix the dll issues.

To answer your last question, SP 2010 required .Net 3.5 and it will not work with .Net 4.0

4
  • Sorry if I don't understand you well, but, when you said check if (wsp) is still available on the Farm did you mean that I check if the wsp is selectable for add the webpart in the page?. The Microsoft.SharePoint.dll runtime version used is v4.0.30319 / version 15.0.0.0 and this version is the one whcih we working since more than a year. Jul 25, 2016 at 20:03
  • I mean check the central administration to see if the solution is deployed. Jul 25, 2016 at 20:41
  • The solution is deployed. Sorry for the late reply. I'm struggling about the DLL registration. I really don't understand why these DLL's need to be in the first location (i.e C\Windows\assembly) and I remember very well that this wasn't a problem a few months ago. I tested againg add the webpart and the same error (detailed in my question) ocurrs. Jul 26, 2016 at 14:53
  • SP 2013 uses .Net framework 4.5 . I had a wsp which was developed for 2010 using .net 4.0 and it kept on giving me an error and then I realized that some of the classes had changed in 4.5 ,please check .net framework also retract the solution go to the 15 hive and delete the whole folder and try to redeploy -- good luck
    – user17970
    Jul 28, 2016 at 21:33
0

This might occur because of assembly 'sample_1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f1cd0442b97c7541' or one of its dependencies entry has been removed from SharePoint Web APplication web.config file.

To overcome this issue

  • Try to retract and redeploy the solution again . (Redeploy process will let you solve the missing entry in web.config by installing your solution again and register DLL to GAC)
  • Also, If you have already added a reference to an external DDL's like ajax to your solution make sure that it has already manually located at C:\inetpub\wwwroot\wss\VirtualDirectories\80\bin (change port based on your web application)
2
  • Dear, If this answer is useful. Please, don't hesitate to upvote it and if it considered an answer to your question you should also set it as Answer, I am also here if you need more clarification Jul 25, 2016 at 21:04
  • Checked the web.config file and it has the entries in SafeControls tag. I'll edit my question. Jul 25, 2016 at 21:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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