Entity Framework 6 with Sharepoint 2013 - sharepoint

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.

Related

Build error Could not load file or assembly Microsoft.CodeAnalysis

We have a .net core 3.1 solution, which we are able to compile (using Visual Studio 2019) and publish. We gave the solution to our team which is setting up the deployment process. While trying the build (linux container) they are seeing the below error:
CommonLib -> /srv/jenkins_work/DSS/ewcms/CMS/CommonLib/bin/release/netcoreapp3.1/CommonLib.dll
CSC : error CS8032: An instance of analyzer Microsoft.EntityFrameworkCore.InternalUsageDiagnosticAnalyzer cannot be created from /var/lib/jenkins/.nuget/packages/microsoft.entityframeworkcore.analyzers/5.0.9/analyzers/dotnet/cs/Microsoft.EntityFrameworkCore.Analyzers.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=3.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.. [/srv/jenkins_work/DSS/ewcms/CMS/Microsoft.EntityFrameworkCore.UnitOfWork/Microsoft.EntityFrameworkCore.UnitOfWork.csproj]
The file mentioned Microsoft.EntityFrameworkCore.Analyzers.dll is there in the folder mentioned in the error. other projects in the same solution have this as a warning, but this particular project shows it as an error.
Reading online many said to install Visual Studio, but that is something they said they can not do in the container, is there another way to get around this issue? Or something in particular we need to look at in that project which is causing and error rather than a warning?
After some investigation, turned out that project had the setting:
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
which was not there in the other projects, which were showing it as warnings only. Changed this to false and this project is also going through now, it comes up as a warning and allows the build to go through.

Project is targeting frameworks not installed or are included as part of future updates to Visual Studio

I am attempting to convert the Microsoft.Health C# class library that is installed as part of the HealthVault SDK, using instructions provided here. After following these instructions, I get the following error when attempting to load the project into Visual Studio 2013.
"The project is targeting frameworks hat are either not installed or
are included as part of future updates to Visual Studio. See
http://go.microsoft.com/fwlink/?LinkId=287985"
Visiting the link takes me to .NET SDKs and Downloads. Once there, I have no clue on what needs to be done.
I do realize that one will have to leverage the Portable Class Library Contrib project to fill in some missing bits, especially code related to System.Security. This, I will deal with later.
Any one run into a similar problem?
Maybe so late but for those who have the same problem.
I had the same error in a project which was working perfect before updating VS2013 and finally after 3 hours looking for the source of the error I found that the error is about TargetFrameworkProfile.
In my case I sloved it like so:
Right click in the unloaded project in your solution and click Edit.
Find the TargetFrameworkProfile tag and set it as below:
<TargetFrameworkProfile>Profile78</TargetFrameworkProfile>
At a guess, this is because you need to specify the TargetFrameworkVersion and TargetFrameworkProfile properties in the project file. Compare the .csproj you are trying to create to a newly created PCL project file, and make sure that everything that's not specific to your project matches.
I ran into the same issue and got it resolved by installing the latest Visual Studio Update

LiteServAndroid could not able to configuring project

Liteservandroid is an application that is used as Http api/Restful api to connect to CouchDB from TouchDB. I got a sample project and when i tried to build the project, i got the following error.
Gradle: A problem occurred configuring project ':LiteServAndroid'.
Failed to notify project evaluation listener.
Configuration with name 'default' not found.
There were no pointing errors in the code section. Can any one help me to find a solution.
Thanks
Chinna
The first hint I see with your problem is that in August 2013 you are talking about TouchDB - and TouchDB name change was introduced as far back as January 2013. There are old projects sitting out there using out of date code.
Are you sure you are using the newer code base? Here is the direct link to the ListServAndroid project https://github.com/couchbaselabs/LiteServAndroid
I found Couchbase Lite to be a bit tricky to integrate. They have moved it all over to Android Studio for building and developing too... so that might be new learning also. Have you gotten the GrocerySync test application working?

Loading web role in Azure emulator results in a BadImageFormatException

I have an ASP.NET MVC project that loads fine when I start it directly. When I try to run it vai the Azure SDK's emulator, I get the following exception:
Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\62253e0e\13ba4ff3\App_global.asax.a-wnopwm.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
This usually indicates something like a reference to a 64bit assembly on a 32bit system, but I've never seen this error on a ASP.NET project dll. The project configuration is set to AnyCPU. What gives?
The problem was due to the assemblyPostProcessorType attribute added to the system.web/compilation element of the web.config file when I used VS 2012's performance analysis (profiling) tool. It doesn't appear to clean up after itself very well and the config was left in place, causing an apparently assembly platform mismatch. It also caused problems when publishing to Windows Azure because the post-build assembly wasn't available.
The solution was to add a transform to the web config transform to remove the attribute (assemblyPostProcessorType).

orchard cms: module package not installing

Setup:
I have created a module that works fine in the solution where it was created, ie, the orchard source code. I then package it up using package create.
Edit: I now realize that the problem appeared IMMEDIATELY after installing visual studio 2012.
Problem:
If I now install the module on a different app using the package and install from file, all the alerts show the module is installed, it appears in the features list, it is enabled... but there are no menu items, no entry in the migrations table, nothing.
Edit: Nothing appears in the logs. The files are, however, installed correctly in the modules folder of the site.
Question:
What could be going wrong that stops the module being properly installed using the package given that the module works fine in the source code solution where it was created??
Any suggestions?
Edit:
How could installing visual studio 2012 have affected Orchard?
I notice that installing visual studio 2012 resulted in various bits of sql server 2012 being installed at the same time. Could this be relevant? EG, is this why the migrations code never runs?
Edit on the basis of Bertrand Le Roy's comments (see below this question):
BertrandLeRoy says that having ASP.NET MVC 4 installed in the GAC, as well as Razor 2 (both of which came with VS 2012), is the problem.
He suggests upgrading to Orchard 1.5.x.
However:
I have tried using a new install of Orchard 1.5.1, and the problem is the same:
Creating a new module using VS 2012 and Source Code for Orchard 1.5.1 and the module appears correctly when running the orchard site from VS.
Creating a package and then installing that into an Orchard 1.5.1 site, eg, using WebMatrix, running and then installing the package has the following effect:
2.1. The alerts in the dashboard tell me that the package has installed correctly.
2.2. However, enabling the feature does nothing.
2.3. This is hardly surprising, as installing the package has not even run the migrations.
The last test I can do is to see if the package runs on a web server that doesn't have asp.net mvc4 installed. I will post back once that is done.
However, the main point is that using Orchard 1.5.1 produces the exact same result. So, if the problem really is the fact that MVC 4 and Razor 2 are on the machine, then Orchard 1.5.1 is not solving it.
Ie, what will happen when I install mvc 4 on the web server as I will inevitably have to for other, non Orchard apps?
I experienced the same thing on version 1.8.1. That is, the module appeared to install fine, but it didn't actually perform migrations or load correctly.
Initially, I saw nothing in the log to indicate a problem. However, after adjusting the /Config/log4net.config file to log ALL instead of just ERROR messages. I got this:
... Orchard.Environment.Extensions.Loaders.PrecompiledExtensionLoader -
- Extension "Transformalize" will not be loaded as pre-compiled extension
because one or more referenced extension is dynamically compiled
The part saying my module "will not be loaded as pre-compiled extension because one or more referenced extension is dynamically compiled" seemed to explain why my module wasn't loading. So, I Googled and found this documentation regarding the Orchard module loader and dynamic compilation. It's a bit complicated at 2 AM, but what I gathered is my module's reference to another module (Orchard.Autoroute in this case) caused the log message (above) in the production environment. I removed my module's reference and dependency on Orchard.Autoroute, and then it installed fine.
The documentation explains how modules are dynamically compiled and how the settings in /Config/HostComponents.config can change how things work.

Resources