'compilerVersion' attribute in the provider options must be 'v4.0' or later - web-config

Getting this error:
The value for the 'compilerVersion'
attribute in the provider options must
be 'v4.0' or later if you are
compiling for version 4.0 or later of
the .NET Framework. To compile this
Web application for version 3.5 or
earlier of the .NET Framework, remove
the 'targetFramework' attribute from
the element of the
Web.config file.
It was working on our dev system, and we are now deploying to QA using an xcopy type deploy.
We don't have a "compilerVersion" anywhere in the web.config, and the targetFramework is set to "4.0". We have done an IISReset.
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
UPDATE 2: when we removed the entire section, we got past the error. So my question is, what is wrong with leaving in this section if we are on .NET 4.0?
We just did a full xcopy of exactly what was in Test to QA, and in QA it gets the error and DEV doesn't. So the software and configs are identical. Why would it work on one server and not another? IIS options seem to be identical.

taken from: http://www.asp.net/whitepapers/aspnet4/breaking-changes#0.1__Toc256770150
you should go to your server root web.config and include the whole
<system.codedom>...</system.codedom>
tag content into a
<location path="" inheritInChildApplications="false">...</location>
tag

Possible solution here - asp.net/whitepapers/aspnet4/breaking-changes#0.1__Toc256770150

After fighting with this for a while, I ended up creating a new IIS site using a different port and adding my ASP.Net 3.5 application to the new site and it is working perfectly.

I got the same error and found out that my v4.0 website was hosted under the default website that was v2.0. If you've such setup then you need to remove the following line from your web.config:
<compilation defaultLanguage="c#" debug="true" targetFramework="4.0"/>
I hope that helps.

Related

Empty the log file every time I write with Enterprise Library Logging

I have Enterprise Library Logging used in my project which is working fine, but I need only the last entry to be saved at any time. Is there any configuration for that?
Below is my current configuration.
<add name="WorkflowListener" formatter="Workflow Formatter" fileName="..\#data\logs\Workflow_log.txt" timeStampPattern="yyyy-MM-dd-HH-mm-ss" rollFileExistsBehavior="Overwrite" rollInterval="None" header="" footer="" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

Error 500 adding Entity Framework to web.config on asp.net web api

In an ASP.net 4.5 Web Api, locally and in production environments is working fine.
I added the Nuget package Entity framework 6.1.3 to the solution. Without adding model. Locally with EF it is working, but when I publish to production, it throws "error 500".
EF add lines to the web.config:
<configSections>
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory
type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient"
type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
In production, when I remove these lines, it works fine (of course without EF).
I tried adding a model then cause the API throws 500.
Is there any way to use EF in this hosting?
Is a problem in the web.config or in the hosting? The api is in a second level directory of a MVC web app.
pd: The hosting uses Managed Pipeline Mode: Integrated.
More info:
When i GET from browser http://max-prueba.somee.com/api/Position/41
it response a status 500 and Server Error
500 - Internal server error. There is a problem with the resource you
are looking for, and it cannot be displayed.
Next step i add line to web config to view description of the error
<customErrors mode="Off"/>
But the response is the same.

ActiveReports WebViewer Looks great in Dev, bad in Staging

I have an ActiveReports WebViewer working great in my development environment. I deployed it to a staging server (Windows 2008 R2 which is IIS7) and I don't get errors, but the viewer looks all crazy. Can anyone point me in the right direction? I've been playing around with HTTP handlers and nothing changes the way it looks. The left pane of the viewer, which can be printing options or report parameters is stretched across the top and the images are broken. Also, the report area that normally displays the report is shrunken up and the report doesn't show. I don't have a high enough rep to post the screen shot, so I hope I have described it enough.
Please ensure that the Web.config on the staging server matches your Web.config on your dev machine ie, please make sure that the Version attribute on each assembly matches the version of your DLLs
<system.web>
<compilation targetFrameork="4.0">
<assemblies>
<add assembly="GrapeCity.ActiveReports.Extensibility.v8, Version=8.0.133.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" />
<add assembly="GrapeCity.ActiveReports.Diagnostics.v8, Version=8.0.133.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" />
<add assembly="GrapeCity.ActiveReports.Chart.v8, Version=8.0.133.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" />
<add assembly="GrapeCity.ActiveReports.Document.v8, Version=8.0.133.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" />
<add assembly="GrapeCity.ActiveReports.Export.Html.v8, Version=8.0.133.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" />
<add assembly="GrapeCity.ActiveReports.Export.Pdf.v8, Version=8.0.133.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" />
<add assembly="GrapeCity.ActiveReports.Export.Image.v8, Version=8.0.133.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" />
<add assembly="GrapeCity.ActiveReports.v8, Version=8.0.133.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" />
<add assembly="GrapeCity.ActiveReports.Web.v8, Version=8.0.133.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" />
</assemblies>
</compilation>
</system.web>
Next, ensure that the DLLs are being published to the bin folder on the staging server as well.
Regards,
Mohita
I figured it out. It was actually a css issue. I am generating the webviewer using JavaScript, like in the Mobile example provided by component one, though I extended it to do things a little differently. I hadn't copied over the css file! Whoops!
Make sure all the assembly references to GrapeCity.ActiveReports are set to Copy Local true.

entity framework code first migrations from seperate windows class library

i have a solution that contains an MVC project and windows class library project that uses entity framework and is a data access layer. I tried to enable migrations with the following package manager console line
Enable-Migrations -ProjectName PortlandRoad.DAL -ContextTypeName PortlandRoadDBContext -Force
I try to update the database using the following line
Update-Database -Verbose -Force
if i do this with the mvc project as the startup project it works, but uses the connection string in the mvc project web.config. If i do this with the dAL project as the startup project i get the following error :
A file activation error occurred. The physical file name '\PortlandRoadDB.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation.
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
the app.config file for my DAL project is as follows :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!--<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />-->
</configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=PortlandRoadDB;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\PortlandRoadDB.mdf" providerName="System.Data.SqlClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
</configuration>
can anybody tell me how to correct this so that the migrations work specifically for the dal project and are not dependent on the MCV project being the startup project
thanks
I've the same issue in a WPF project.
I think that you have two options.
Option 1
At startup in you windows project try to specify the correct path to your database using
AppDomain.CurrentDomain.SetData("DataDirectory","your\physical\path");
With this, you will have the same error but your migrations can still being applied to your principal database.
option 2
Find a way to replace dynamically this |DataDirectory| in your app.config file before starting your application. (.bat , or .ps or ...).
another option: The bad one.
Before running your migration change the path to you DataDirectory to a physical temporary one in your app.config (this file will help you keep up to date migrations history)
before launching your application replace the temporary file path by |DataDirectory| and change this parameter in your startup with the App.config
With this work around, if your are planning to deploy your application, you will keep track of all migrations in order to anticipate futures database modifications.
VoilĂ .
Could it be that you're using "|DataDirectory|" in the connection string in the DAL project? Since "|DataDirectory|" is an Asp.Net folder and the DAL project is not an Asp project it probably doesn't recognize that as a directory and it probably doesn't exist thing the DAL project.

WebMatrix 2 doesn't recognize EntityFramework helper

I just started to work on WebMatrix, I did this tutorial to learn the basic and then I started with this one to get started with Entity Framework on WebMatrix (Note: That tutorial is for WebMatrix 1, but the only thing I see changed was the way you install helpers into your project). The thing is, I installed the Entity Framework helper, but my project doesn't recognize the EntityFramework.dll.
I get this error The type or namespace name 'MaxLength' could not be found (are you missing a using directive or an assembly reference?). But the EntityFramework.dll does appear in my bin folder, what is going on? I don't understand why the reference isn't working.
This is my Web.config file according to the second tutorial and after installing the EntityFramework helper:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.0"><assemblies><add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /><add assembly="System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /></assemblies></compilation>
</system.web>
<connectionStrings>
<add name="BookContext" connectionString="Data Source=|DataDirectory|Books.sdf" providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
</configuration>
This is the compiler output link
Am I missing something? Why does the EntityFramework.dll isn't being recognized properly by my project?
UPDATE
I thought the problem was solved when I copied the EntityFramework.dll from a webpage project created in Visual Studio 2012, but even though the errors aren't shown anymore, WebMatrix still doesn't recognize annotations like Table, Column, ForeignKey, InverseProperty, etc.
I really don't understand, a simple database is created but I can't use the EntityFramework annotations to specify all I need for the database. WebMatrix should recognize the EntityFramewor.dll but it is not. I need help in this one because I'm really lost.
The error that you see is the end result of the version of EntityFramework installed on your site.
The EntityFramework 5.0 package installs version 4.4 or 5.0 of the EntityFramework.dll depending on the version of .NET (4.0 or 4.5) that the project is targeting.
In my experience, installing EntityFramework from the NuGet Gallery in WebMatrix always copies version 4.4 of EntityFramework.dll into the bin folder: you can check it looking at Properties --> Details of the EntityFramework.dll file.
The only solution I know is to download EntityFramework v.5.0 using VisualStudio Express or another standalone utility (look at this post: Install Entity Framewok v5 in Webmatrix 2 RC) and simply replace the dll installed by NuGet Gallery in WebMatrix with this one.
UPDATE
Other problems experimented with EntityFramework v.5.0 and WebMatrix are that the type 'System.Data.EntityState' is defined in an assembly that is not referenced and that is needed a using directive for DataAnnotations.Schema.
The first problem is resolved adding the following reference to web.config (look at Could not load file or assembly 'System.Data.Entity):
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
The second problem needs the addition of the directive
using System.ComponentModel.DataAnnotations.Schema;
to the code.
Anyway, in my opinion WebMatrix isn't the right tool for developing a site based on EntityFramework.