Cannot load library into assembly (GAC) - sharepoint

I am using visual studio 2010 on windows server 2010 with Sharepoint 2010 server. I am deploying webparts to a Sharepoint instance running on the same server.
My new webpart makes use of a custom library, AE.Net.Mail. When I deploy this webpart, I get the Could not load file or assembly... error for AE.Net.Mail. I have run gacutil but I do not see the assembly in C:\Windows\assembly. I do see it in a subdirectory of C:\Windows\Microsoft.NET\assembly.
Now I am not sure about this but I think when my Sharepoint instance runs, it only looks at C:\Windows\assembly. And that is why it is not able to find the library. The reason I believe this is that the name of my webpart is present in C:\Windows\assembly. It's being cached there and not in a subdirectory of C:\Windows\Microsoft.NET\assembly.
I am using version AE.Net.Mail Version 1.6.0.0 which is compatible with .NET 3.5. I think my Sharepoint server is using 3.5 although 4.0 is present on the machine. I think so because when I tried to install the the library using nuget, I couldn't install the latest version that requires .NET 4.0. The error said that my project is using 3.5. Version 1.6.0.0 is compatible with 3.5
So, what do you guys think is going on and how do you think I can get AE.Net.Mail into C:\Windows\assembly? Been at this for hours now and I can't figure it out (Dragging and dropping doesn't work)
Thanks guys. :)

Judging from the sources AE.Net.Mail isn't strongly typed which is something GAC-deployment (and SharePoint) require.
To add the binary to the GAC you must download the binaries of AE.Net.Mail from Github, sign the assembly and compile it yourself. This is easy, simply follow this guide http://msdn.microsoft.com/en-us/library/ms247123(v=vs.100).aspx
Remember to compile for .net 3.5 since that's what SP2010 supports, it wont recognize net4 assemblies

Related

Telerik.Windows.Controls.DataVisualization, version- 2013.3.1316.45 is not supporting

I am using telerik RadTreeMap control. It is showing error when we use DLL Telerik.Windows.Controls.DataVisualization, version- 2013.3.1316.45 is not supporting. when I use version - 2013.3.1316.40 then it work fine. But all over in our application we already used the DLL of version 2013.3.1316.45 and we cant use the old version DLL 2013.3.1316.40. So how we can use the DLL version 2013.3.1316.45 In RadTreeMap application, please give the solution as early as possible.

TFS Server Side Plugin no longer works in 2013

I had created (modified an existing project) a server side plugin that has been working (on TFS 2012) for quite awhile. When I upgraded the server to 2013, I copied the .dlls over to the same folder within the 2013 directory structure (Application Tier\Web Services\bin\Plugins), but it no longer works.
I installed remote debugging, attached my debugger to the w3wp.exe process (like here: Problem with Custom TFS Web Service Plugin), and performed check-ins. I'm pretty sure everything was in place because the first time I tried Visual Studio reported that symbols weren't loaded, but after copying up the .pdbs it looked
good. The ProcessEvent method never hit.
I can't find any new documentation on this stuff, guess this is just desperation, does anyone know what to do to make my plugin load?
You need to recompile the plugin against the 2013 assemblies (there are tricks using binding redirects, but if you have the sources, please just recompile). And you need to set the .NET framework version to .NET 4.5 in order for the solution to compile (the TFS 2013 binaries target that framework version, so your plugin must target either 4.5 or higher in order to reference these assemblies).

Version SharePoint WSP

Has any one tried to version WSP in SharePoint 2010?
Thanks,
It would help to be a bit more specific that ".wsp" in your question.
As Flo mentioned - if you keep the assembly version the same but change the AssemblyFileVersion then you can upgrade the assemblies in your WSP solution using
STSADM -o upgradesolution ...
See my answer on SO - How can I use wildcard assembly versioning?
This will suffice for webparts but if you've got other artifacts and are using things like Feature things like event receivers then you may have to retract and re-deploy.
Thanks all for your replies. I have two concerns:
a. Assume my wsp is deploying a webpart with assembly version as 1.0.0.0 and assembly file version is also 1.0.0.0. Now after few days i need to deploy a recent version of webpart. The assembly version now will be 2.0.0.0 and assembly file version will also be 2.0.0.0. I have noticed that even if i retract and redeploy the wsp, the .webpart files that sits in the web part gallery always shows assembly version as 1.0.0.0. I guess this is because wsp retraction will not delete the .webpart file and neither feature deactivation. So the only option that remains is to write feature deactivation code to delete the .webpart file from webpart gallery. This will be largely in efficient as i will need to iterate through all the site collections of deployed webapplication to determine from the code ( a windows form as installer) the site collection where feature is activated and deactivate the same.
b. I need to query the webpart dll version for some operation. I was thinking it will be good if we can version wsp and keep the wsp version same as the web part dll. This will help me to remain in the SharePoint context to determine the web part dll version ( rather than querying the dll to find the version).
Thanks
WSP don't really version.
You can however version components into it:
Feature or WebParts via different names (FeatureV1, FeatureV2...)
Assembly using standard assembly versioning (WebpartV1 use assembly 1.0.0, WebPartV2 use 1.1.0 and so on)
...

Sharepoint WebPart, include additional assembly in wsp package

I created a utility library for my Sharepoint WebParts. Now when I reference this library from my WebPart project, it compiles fine, but the library is not included in the .wsp package. This means the library assembly is not deployed to the target system, causign the WebPart to fail.
Is there any way to fix this? I am using Visual Studio 08 & VseWSS 1.2.
Brij's answer is partially correct, your VSeWSS version is the problem. This feature only came in version 1.3 (I recommend the March CTP) to have the CopyToLocal=true automatically add the assemblies to the GAC for you.
Right click of Assembly > Properties
Set “Copy Local” property = true
Build project.
See following for more details:
http://urenjoy.blogspot.com/2009/08/add-assembly-wsp-vsewss.html

Could not find assembly System.ServiceModel

I'm deploying a webpart on sharepoint and getting some errors. The webpart consumes data from a Web Service and displays a chart using Microsoft Chart (Framework 3.5). When I try to acces it, I get the folowing error:
Could not load file or assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
StackTrace: at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
I tried copying System.Servicemodel.dll to the bin folder and registering it on the GAC, but the error does not change.
Any idea?
Thanks
To expand on the above answers:
It does sound like your site is running on asp.net 2.x. Being that System.ServiceModel is a 3.x component, the assembly will not load. You will need to install 3.5 on the server, or if you already have it set IIS to run the site under 3.5
I had a similar problem, but it was because my .NET framework got messed up/corrupted, so I'll post what fixed it for me. Maybe it's overkill, but it worked when nothing else would.
Get the “dotnetfx_cleanup_tool” from http://blogs.msdn.com/b/astebner/archive/2008/08/28/8904493.aspx (I think one of the download links fails, so use the other one)
Uninstall frameworks 2.0 and above (I did 3.5, 3.0, 2.0. 2.0 made me reboot).
IMPORTANT: Go to C:\WINDOWS\Microsoft.NET\Framework and delete or rename the folders for the versions of .NET you removed.
Then I installed .NET Framework 2.0 SP2 (reboot afterwards). The error was gone.
I also installed .NET Framework 3.5 SP1 (works without rebooting) and the error was still gone.
Is your website configured to use ASP.NET 2.0.5.something ?
Maybe this article can be helpfull:
Forcing ASP.NET 3.5 ON IIS
Try installing .NET Framework 3.5 on your sharepoint server.
It sounds like the Web Part itself was built against an older version of the System.ServiceModel assembly (probably a beta version). If you have access to the web part's source code, you should recompile it against the latest stable version. Otherwise you'll have to find the exact same version of System.ServiceModel and register that into your GAC.
EDIT: You could also try going into your web app's Web.config and replace your System.ServiceModel reference with this:
<Reference Include="System.ServiceModel">
<SpecificVersion>False</SpecificVersion>
</Reference>
The problem was within the Web Service, not the webpart.
The machine where the web service was deployed has framework 2.0 installed.
The exception was catched on the webpart and reported back.
Thank you all for your comments.
fire up your Visual Studio 2010 Command Prompt or browse to "C:\Windows\Microsoft.NET\Framework\ v4.0.30319". And run the following command from the command prompt:
aspnet_regiis.exe -iru
I came across this same problem with a Silverlight 4 app and solved it by switch off Debug Exception checks for
Common Language Runtime exceptions
in Debug => Exceptions
Hope that helps
Mike

Resources