As part of plans to migrate an existing website from .NET 4 to .NET 4.5.1 we have learned that we will need to move from using Enterprise Library 5 to version 6.
We're using the caching block in version 5, but this has been removed from version 6, so we plan (as recommended) to refactor our code to use System.Runtime.Caching instead.
We would like to ensure that the settings (in Web.config) we will for System.Runtime.Caching will give us the same (or similar...) behaviour as those we currently use for the Enterprise Library 5 caching block.
The Enterprise Library 5 caching block settings we are currently using are:
<configSections>
<section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<cachingConfiguration defaultCacheManager="Cache Manager">
<cacheManagers>
<add name="Cache Manager"
type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
expirationPollFrequencyInSeconds="60"
maximumElementsInCacheBeforeScavenging="1000"
numberToRemoveWhenScavenging="10"
backingStoreName="NullBackingStore" />
</cacheManagers>
<backingStores>
<add type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="NullBackingStore" />
</backingStores>
</cachingConfiguration>
The System.Runtime.Caching settings we are planning to use are:
<system.runtime.caching>
<memoryCache>
<namedCaches>
<add name="default"
cacheMemoryLimitMegabytes="10"
physicalMemoryLimitPercentage="0"
pollingInterval="00:01:00" />
</namedCaches>
</memoryCache>
</system.runtime.caching>
Are we on the right track here?
Note that we do not have comprehensive load testing facilities for our website, so are not able to satisfactorily test our use of caching before we release the website.
Related
Using Visual Studio 2015 & Sitecore 8.0
I have created a new MVC project with .Net Framework 4.6.1, copied, and referenced the Sitecore.kernel.dll & Sitecore.mvc.dll. Replaced the existing web.config & global.asax with the sitecore files.
Added a plain HTML page in the solution and tried to browse it (from VS). The page opens with this error
Could not load file or assembly 'System.Web.Http, Version=5.1.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The system cannot find the file specified.
This HTML page is not published to Sitecore yet. I'm guessing, the Sitecore.mvc.dll wants MVC 5.1.0 and the MVC in VS project is 4.0.
So, I tried the following steps.
Run install package command in package manager console for MVC 5.1.1 which shows the error
Unable to load the service index for source
https://api.nuget.org/v3/index.json.
Deleted the %AppData%\NuGet\nuget.config and restarted VS2015
Manually browsed https://api.nuget.org/v3/index.json, but the page doesn't load - Secure connection failed. But this - http://api.nuget.org/v3/index.json will promt to download the json. So, in the nuget changed https to http, but its the same error - Unable to load the service index...
I'm not even able to start my first Sitecore MVC project when this happens.
I replaced the sitecore web.config with the regular VS project's web.config and now I'm able to browse the page. I set its Copy To Output Directory to Do not copy, so that it will not get published.
Will I be able to proceed with my Sitecore development this way without any major issues in future.
You need to do a few things to fix this:
Your VS project should be updated to have the web.config file from the Sitecore installation. You must have the Sitecore version of that file or Sitecore will not run correctly
You should add a binding redirect for the MVC file that makes everything use the latest version:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
</assemblyBinding>
etc....
</runtime>
Make sure that the web.config file in your /views folder contains the correct versions of all the MVC assemblies. This is mine for a .net 4.6 application:
<configSections>
<sectionGroup name="system.web.webPages.razor"
type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host"
type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
requirePermission="false" />
<section name="pages"
type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host
factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="Sitecore.Mvc" />
<add namespace="Sitecore" />
</namespaces>
</pages>
</system.web.webPages.razor>
Once that is done, your Sitecore installation should pick up the latest MVC binaries correctly.
I use Visual studio 2013 (Windows) to build a small .NET 4.5 application using Npgsql and Entity Framework 6.
On windows it just works fine.
But on Raspbian, the app crash saying it cannot find npgsql provider.
Unhandled Exception:
System.Configuration.ConfigurationErrorsException: Failed to find or load the registered .Net Framework Data Provider 'Npgsql'.
at System.Data.Common.DbProviderFactories.GetFactory (System.String providerInvariantName) [0x00000] in <filename unknown>:0
[...]
On my raspberry pi 2.
I have manually installed Mono v4.0.2
I have copied my app including:
npgsql.dll v2.2.5.0
npgsql.entityframework same version
mono.security v4.0.2
and my app.config contains :
<?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=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<providers>
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" />
</providers>
</entityFramework>
<connectionStrings>
<add name="minitestEntities" connectionString="metadata=res://*/Model2.csdl|res://*/Model2.ssdl|res://*/Model2.msl;provider=Npgsql;provider connection string="PORT=5432;TIMEOUT=15;POOLING=True;MINPOOLSIZE=1;MAXPOOLSIZE=20;COMMANDTIMEOUT=20;COMPATIBLE=2.2.5.0;DATABASE=minitest;HOST=10.0.0.1;INTEGRATED SECURITY=True;PASSWORD=azerty;USER ID=theuser"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
So i'm wondering if npgsql librairies are correctly loaded, or a if a reference is missing.
I found no docs on how to use npgsql on recent mono + ARM environment.
Any info about this would be really appreciated.
ok i found the solution in an other discution. In the meanwhile i forgot to note its URL so here the answer :
We have to add manually the provider description into app.config :
<system.data>
<DbProviderFactories>
<add name="Npgsql Data Provider"
invariant="Npgsql"
support="FF"
description=".Net Framework Data Provider for Postgresql Server"
type="Npgsql.NpgsqlFactory, Npgsql, Version=2.2.5.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" />
</DbProviderFactories>
</system.data>
The version and PuclicKeyToken MUST match with npgsql.dll.
To get the public key token, you can run that code :
typeof(Npgsql.NpgsqlFactory).AssemblyQualifiedName
Now i have no idea why this step is not necessary into windows, but a have to do into linux...
I just switched to VS 2015. I have an older MVC 5 app that runs against 4.52. In VS 2013 it's perfectly fine.
In VS 2015 I'm getting red squigglies under my #Html.TextBoxFor() with an error indicating:
The type 'Expression<>' is defined in an assembly that is not
referenced. You must add a reference to assembly 'System.Core,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
The project builds and runs just fine -- but I am concerned about the IntelliSense error that never happened in VS 2013. Okay, so I try to add the reference to System.Core as recommended in the error above and then I get this error:
A reference to 'System.Core' could not be added. This component is
already automatically referenced by the build system.
Again, this is fine in VS 2013.
I had the same issue, but in the mean time I've found the answer:
I had to add the following references to my web.config (add inside the opening system.web tag):
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add assembly="Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
I also changed the target framework from 4.5.1 to 4.5.
p.s Close and reopen Visual Studio after changing it.
I have tried most of these, what eventually worked for me was unloading the project, edit the csproj file, and add the following:
<Reference Include="System.Core" />
In my case (VS 2019) I have to add this in .csproj file after unload the project
<Reference Include="System.Core" />
need to change in ProjectGuid tag like below:
<ProjectGuid>{6C651A5E-8DDA-4680-804E-F9596743CBE8}</ProjectGuid>
then reload the project and add this tag to web.config like below:
<compilation debug="true" ...>
<assemblies>
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
...
</assemblies>
</compilation>
and after that just rebuild the project and all the error is gone in my case.
Only deleting solution and getting solution from source control solved this for me, removing .vs folder and starting VS2015 as "devenv.exe /resetuserdata" did not solve my problem, event removing MEF component cache did not solve as per Razor intellisense not working in VS 2015 answers.
In my case, it worked after changing the tag <ProjectGuid> in .csproj file to <ProjectGuid>{6C651A5E-8DDA-4680-804E-F9596743CBE8}</ProjectGuid> and reopening the solution. All of the solutions posted above did not work for me.
From updating from 4.5.2 to 4.6.1 I got these exact errors in my views. Building and running the solution worked absolutely fine. After trying all the solutions already posted here, (and also checking intellisense for working, clearing caches, removing bin and obj folders, loading and reloading the project) nothing worked whatsoever (system.core was already being built correctly and adding in those references to the Web.config did nothing). I did my own digging and eventually found that in the project where the error was occurring the Web.config file contained two compilation debug target frameworks and a different httpRuntime target framework. Like so:
<system.web>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.6.1" />
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.1" />
...
The solution was to resolve this by removing the extra compilation debug target framework and to ensure all target frameworks were the one I wanted (4.6.1)
<system.web>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1" />
...
Double check this if nothing else works. Hope that helps someone!
If anybody is facing this issue with
VS 2017 , .net framework version 4.8 and MVC version 5.2.7
Then check your Microsoft.CodeDom.Providers.DotNetCompilerPlatform version, If you have 2.0.1 version installed then downgrade it to 2.0.0
Then check the MVC version, you have to downgrade it to 5.2.4
Then downgrade Microsoft.AspNet.WebPages 3.2.7 to Microsoft.AspNet.WebPages 3.2.4
and Microsoft.AspNet.Razor 3.2.7 to Microsoft.AspNet.Razor 3.2.4
try to run the application now, it will work.
I tried these and other solutions on other Stack Overflow threads. None worked.
What worked was repairing the installation of Visual Studio which is found in the System Settings, Apps & features sub-menu (click on VS and choose "Repair"). It took a couple of hours, but then the problem disappeared.
As I got a pitch for future project specifying XP compatibility I'm trying to test combination of VS 2010 (WinXP SP3), .Net 4.0.3 (later WPF for UI), Entity Framework 6 (as I found out it should be compatible with .Net 4) and SQLite (System.Data.SQLite / .EF6).
I installed "EntityFramework" and "System.Data.SQLite EF6" packages from NuGet.
("System.Data.SQLite EF6" in turn installed System.Data.SQLite, System.Data.SQLite.EF6 and SQLite.Interop.dll)
Now trying to use "Ado.Net Entity Data Model" template, which I guessed from older tutorials would be next step I get to new connection dialog and no SQLite provider is listed there to select.
I checked my App.config and SQLite data providers are listed there. (If correctly I can't tell)
Looking like this:
<?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=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0.3,Profile=Client" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite" />
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider (Entity Framework 6)"
invariant="System.Data.SQLite.EF6"
description=".Net Framework Data Provider for SQLite (Entity Framework 6)"
type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
<add name="SQLite Data Provider"
invariant="System.Data.SQLite"
description=".Net Framework Data Provider for SQLite"
type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data>
</configuration>
The app (empty console app) compiles without errors and runs (doing of course nothing).
I am pretty green with EF + SQLite so can you please advice ?
Am I completely on a wrong track with something ?
So after another several hours of desperate googling I found a hint in an old tutorial about Visual Studio Design Time Component(s).
Apparently I was missing the Design Time Components and also System.Data.SQLite libs installed in GAC, without which VS2010 wizards don't 'see' the SQLite provider.
So despite reading in numerous official places that Setup install package is not a recommended method of getting SQLite libs into the project, it is actually the only way of making VS (2010, 12, ?13?) tools work with it.
Istalled one of "setup packages" from http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki . In my case "Setups for 32-bit Windows (.NET Framework 4.0)".
The Template now offers SQLite as data provider.
I had an asmx service in .NET Framework 3.5 which I have now converted to .NET Framework 4.0. Now I want to run this service as WCF service with the same ASMX extension. I read a couple of blogs which have step y step procedure to convert them. However they all refer to .NET Framework 3.5. Here are the references I got from internet.
http://weblogs.manas.com.ar/waj/2007/05/31/asmx-to-wcf-migration/
http://blogs.msdn.com/b/wenlong/archive/2007/09/18/how-to-use-asmx-extension-to-handle-wcf-requests.aspx
I tried these and they work well with 3.5 framework but not with 4.0 framework. I got the error
Unable to cast object of type
'System.Web.Compilation.BuildResultCustomString'
to type
'System.Web.Compilation.BuildResultCompiledType'.
on which I added httpHandler section and it was gone. However now I get a new error
Could not load type
'System.ServiceModel.Activation.HttpHandler'
from assembly 'System.ServiceModel,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'
Can anyone help me out with this error.
I got it working with aspNetCompatibilityEnabled set to 'true' like this:
Add a reference to:
System.ServiceModel.Activation
in your web.config:
<system.web>
<compilation debug="true" targetFramework="4.0">
<buildProviders>
<remove extension=".asmx"/>
<add extension=".asmx" type="System.ServiceModel.Activation.ServiceBuildProvider, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</buildProviders>
</compilation>
</system.web>
<system.webServer>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<add name="MyNewAsmxHandler" path="*.asmx" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
mind the type and publickeytoken changes in the handler! It has to be 'System.ServiceModel.Activation' in stead of 'System.ServiceModel' and 'PublicKeyToken=31bf3856ad364e35' as Microsoft has split these into seperate assemblies
I think you may need to register the .NET 4 handlers in IIS properly. Run ServiceModelReg.exe -ia from the .NET 4 framework directory and see if it helps.
C:\Windows\Microsoft.NET\Framework\v4.0.30319>ServiceModelReg.exe /?
Microsoft (R) WCF/WF registration tool version 4.0.0.0
Copyright (c) Microsoft Corporation. All rights reserved.
Administration utility that manages the installation and uninstallation of
WCF and WF components on a single machine.
Usage:
ServiceModelReg.exe [(-ia|-ua|-r)|((-i|-u) -c:<command>)] [-v|-q] [-nologo]
[-h]
-ia
Install all components
-ua
Uninstall all components
-r
Extended only. Repairs all components
-i
Install components specified with -c
-u
Uninstall components specified with -c
-c:<component>
Install/uninstall a component:
httpnamespace - HTTP namespace reservation
tcpportsharing - TCP port sharing service
tcpactivation - TCP activation service (unsupported on .NET 4 Clien
t Profile)
namedpipeactivation - Named pipe activation service (unsupported on .NET
4 Client Profile)
msmqactivation - MSMQ activation service (unsupported on .NET 4 Clie
nt Profile)
etw - ETW event tracing manifests (Windows Vista or later
)
Can be used to install several components at the same time
-q
Quiet mode (only error logging)
-v
Verbose mode
-nologo
Suppress the copyright and banner message
-h
Displays this help text.
Examples:
ServiceModelReg.exe -ia
Installs all components
ServiceModelReg.exe -i -c:httpnamespace -c:etw
Installs HTTP namespace reservation and ETW manifest
ServiceModelReg.exe -u -c:etw
Uninstalls ETW manifests
ServiceModelReg.exe -r
Repairs an extended install