Could not find assembly System.ServiceModel - sharepoint

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

Related

Running Azure functions will result in .net 4.7.1 installation prompt dialog

When I try to run (debug) functions in Visual Studio 2017 on one of our machines, the following dialog pops up!
The target framework for the project is <TargetFramework>net461</TargetFramework>. For some reasons I am not able to install .NET 4.7.1 and now I am completely lost. I am sure it was functioning in the past on the same machine. Probably one of the updates caused it.
Any idea how to resolve it?
This is because the latest version of the Azure Functions Tools for Visual Studio now requires .NET Framework 4.7.1 (as of February 2018).
Note that this does not impact the target framework that you compile against - only the target framework your code runs against. Similarly, when you run in Azure, you can expect the .NET runtime version to be .NET Framework 4.7.1 (at the time of writing).
I tried implementing the solution mentioned in comment. However, it didn't work for me. However, reverting the Azure Functions Tools to previous version worked. Thanks Chris for pointing that it was Azure Tools and not any packages that caused it.
If anyone else should come across this.
For me, the issue was the actual func.exe config that needed to be upgraded.
Navigate to:
C:\Users[USER]\AppData\Local\AzureFunctionsTools\Releases[VERSION]\cli
.. my version was 1.4.0
Modify the func.exe.config to match the .net version installed
.. it was 4.7.1

How are dotnet core assemblies resolved in an asp.net core app hosted in IIS

We have an asp.net core application running on kestrel hosted in IIS on windows server 2008.
This application uses several base components and we are used to just install these components in the GAC and use assembly redirects to point all applications on the same server to the latest version of these components.
Everything runs fine when we deploy the application including all the necessary assemblies.
However, when we apply a redirect on a dotnet core assembly (we apply the redirect in the [app].exe.config, not the web.config) to a version that is installed in the GAC, we get a type exception ...
Application startup exception: System.TypeLoadException: Could not
load type 'my.company.namespace.coolest.component.helpers'
Curiously enough, the redirects for the plain old dotnet4 assemblies work when specified in the [app].exe.config, only the redirect for the dotnet core assembly fails.
So, I'm now wondering. How are dotnet core assemblies resolved? Which locations are searched for ?
(And ultimately, is it possible at all to redirect to a dotnet core assembly in the GAC)
[EDIT 23/OCT/2017:
Doh... turns out the latest dotnet core assembly from our team was bad..
so to answer my own question.. yes, assembly redirects (when specified in [app].exe.config) for dotnet core assemblies targeting full .net framework do work and ARE also searched from the GAC]
ASP.NET Core emphasizes a lot of Self-Contained Deployments, so if any assemblies (including ASP.NET Core runtime itself) of your web apps need to be updated, you should rebuild a deployment package and redeploy.
Framework-Dependent Deployments is just introduced to eliminate some disadvantages of SCD, but it still requires your own assemblies to be repackaged and redeployed if you make certain updates.
So forget about the GAC tricks and assembly redirection your team previously used (many other teams also use similar tricks), and follow Microsoft's new approaches. Maybe one day Microsoft would bring GAC to .NET Core, but that should look completely different from what it is today.
Reference: https://learn.microsoft.com/en-us/dotnet/core/deploying/
As Martin Ulrich indicated, it depends on the targetFramework..
For a .net core application targeting the full dotnet framework, assemblies are loaded just as we are used to.
(all assemblies, including the dotnet core ones)
In my case the assembly manager was loaded from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
For binding redirects, it checks application configuration file / host configuration files / machine configuration file
For retrieving assemblies, it looks in the GAC, then the current directory
Noteworthy, for a .net core application targeting the dotnet core 2.0, a "Runtime Package Store" was recently introduced.
Here the assemblies in the application directory are searched first, then the Runtime Package Store
(See also SO 35538093, Microsoft documentation and Runtime Package Store discussion on github)

Entity Framework 6 with Sharepoint 2013

I tried without success to get a SharePoint 2013 application page or web part to work with Entity Framework 6 (6.0.1 to be exact - the version installed into Visual Studio 2012 by default using NuGet at time of writing).
My code was very simple for test purposes, just reading data from one table.
I could install the package just fine, create models, see that the they were properly configured etc, no problem - but whenever I tried to load the page I got the error:
Event code: 3008
Exception type: ConfigurationErrorsException
Exception message: An error occurred creating the configuration section handler for entityFramework: Could not load file or assembly 'EntityFramework' or one of its dependencies. The system cannot find the file specified. (C:\inetpub\wwwroot\wss\VirtualDirectories\[sitename]\web.config line 36)
I copied all of the config settings from the App.Config file in VS (created by the EF install), into the web.config, verbatim.
I tried every suggested fix I could find on the interweb (e.g. changing the EF assembly ref to "Specific version = false", changing version refs in the config file to the specific version... all sorts) but nothing worked.
I created a console app using the same settings and it worked fine, so I know it's not a server-specific issue - looks like a compatibility issue with SP2013, anyone have any ideas?
I installed EF 5 using the NuGet console, and finally got it working with that... but I'm very curious as to why EF 6 refused to play ball.
Thanks
Poolio
You need to deploy the Entity Framework assemblies (EntityFramework.dll, EntityFramework.SqlServer.dll) as part of your SharePoint solution package. You can reference external dlls in the package.

Cannot load library into assembly (GAC)

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

Can't open NerdDinner project in vs2008

NerdDinner.csproj won't load in vs2008 sp1 with .net 3.5 sp1. Am I not up-to-date on these tools or something? It complains this project type not supported on this installation.
Do you have the ASP.NET MVC Framework installed? If not, you need it. NerdDinner is an example of an MVC Framework project, and you won't be able to open it or run it without the ASP.NET MVC Framework installed.
You can find the appropriate installation information at http://www.asp.net or more specifically http://www.asp.net/mvc
In my I had to change the value of the "ProjectTypeGuids" in the project file. I copied them from another MVC project that I had created with my version of VS 2008.
This is the post that gave me the answer:
http://www.stuffthatjustworks.com/How+To+Fix+Xcsproj+Cannot+Be+Opened+The+Project+Type+Is+Not+Supported+By+This+Installation.aspx
In my case...it was the wrong version of the framework.
I just copied the from another asp.net mvc project I had made. (then you probably have to fix up the references, which is trivial with resharper :-) )

Resources