Celtic Coding Solutions Blog

Celtic Coding Solutions Blog - for everything computer related

Fix - Unable to install Dot Net 3.5 (.Net) on Windows Server 2012 R2

Tried to install Microsoft SQL Server 2012 on a Windows 2012 R2 and had the following error:-

The following error has occurred:

Error while enabling Windows feature : NetFx3, Error Code : -2146498298 , Please try enabling Windows feature : NetFx3 from Windows management tools and then run setup again. For more information on how to enable Windows features , see http://go.microsoft.com/fwlink/?linkid=227143

OK simple enough I thought, so I just used PowerShell and ran:-

Install-WindowsFeature –name NET-Framework-Core

but that got to about 68% and failed.  OK maybe it needed the media (DVD/ISO) of the original VM creation.  So again tried the following PowerShell:-

Install-WindowsFeature –name NET-Framework-Core –source Z:\Sources\SXS

but again got to about 68% and failed - very odd as never had issues installing .Net 3.5 before on a modern server.  Looking around the internet it seemed if you had any of the following KB's installed from the Windows update it was a good idea to remove first:-

  • KB2966826
  • KB2966827
  • KB2966828

But I didn't have these installed as a fairly new server build.

FIX:-

The fix was fairly simple.  On the Server open Group Policy and open the following:- Local Computer Policy -> Computer Configuration -> Administrative Templates -> System

Find the Setting that says:-

Specify settings for optional component installation and component repair

Click Enabled and tick the box that says:-

Download repair content and optional features directly from Windows Update instead of Windows Server Update Services (WSUS)

Click apply and OK, then back in PowerShell run:-

Install-WindowsFeature –name NET-Framework-Core

And thankfully .Net 3.5 will now be installed.

Entity Framework determine storage version SQL Server 2016

Using latest Entity Framework 6.1.3 with Visual Studio 2015 and connecting to SQL Server 2016 developer edition, I had the following error:-

Could not determine storage version; a valid storage connection or a version hint is required.

Fix:-

In Visual Studio Solution Explorer.

Right Click over the Entity Framework .edmx

Open with and select XML Text Editor

Search for "ProviderManifestToken=" and either you will have XXXX or in my case I had 2012 in this value.  So I changed it to 2008 and now my code works.

Entity Framework SQL Server Version Error

Used Entity Framework 6 in Visual Studio 2015 and pulled all the table from the Development Database I needed.  They changed the Entity Framework SQL Configuration line in the App.Config (.Net Command Line App) and got the following error when trying to insert a record:-
The version of sql server in use does not support datatype 'datetime2'. entity framework

Check my SQL Database tables and I wasn't using DateTime2 in any fields.  OK this is a bit strange, the only difference is that Dev SQL Server is running SQL 2008 R2 and Live is still stuck on SQL 2005.

Fix:-
Right click on the *.edmx (Entity Framework Model) file and select "Open With..."
Select "XML (Text) Editor"
Near the top of the XML there is a section that looks like :-
<Schema Provider="System.Data.SqlClient" ProviderManifestToken="2008" Alias="Self" 
The catch here is the ProviderManifestToken is still on 2008, so change this to 2005 for SQL Server 2005 and the error should go:-
<Schema Provider="System.Data.SqlClient" ProviderManifestToken="2005" Alias="Self" 

Visual Studio Compiler error after changing application .Net target framework

Wrote an Asp.Net application using latest Visual Studio 2015 and target framework of .Net 4.5.2. but needed to re-compile it using just .Net 4.5 same as on the web server.  Usually fairly simple just open Applications Project properties and change the Target Framework, re-compile and any errors will be apparent.  However on running the Web App I see the following in the Browser:-

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1617: Invalid option '6' for /langversion; must be ISO-1, ISO-2, 3, 4, 5 or Default

Source Error:

[No relevant source lines]

Fix:-

Kind of tells you why it is failing in the Compiler Error Message so check your Web.Config.  Find the section on <compilers> and check that is is correct.

Mine looked like this:-

<compilers>

  <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701">

  <providerOption name="CompilerVersion" value="v4.0"/>

</compiler>


Everything looks OK but the issue is in the section:-
compilerOptions="/langversion:6 /nowarn:1659;1699;1701"
So change this to:-
compilerOptions="/langversion:5 /nowarn:1659;1699;1701"

Recompile and all will be working again.

CSC.exe crash in Visual Studio 2015 when running Asp.Net project

Using Visual Studio 2015 and a Visual Studio Asp.Net Project I am increasingly getting 2 errors:-

CSC.exe has stopped working (APPCRASH):-


And CPU hitting 100% due to VBCSCompiler showing multiple times taking loads of memory too.


Fix:-

Close all instances of Visual Studio 2015 and if they don't do it automatically disappear, end tasks for all the VBCSCompiler processes.  In your Visual Studio project under Bin folder you will see a roslyn folder (new for VS 2015).

Delete the roslyn folder and all contents within.

Restart Visual Studio 2015, re-compile your project and all should be well again.

Visual Studio 2015 and NuGet redirection and package retrieval errors

Using Visual Studio 2015 and trying to get a package from NuGet I was getting 2 errors:-

Install-Package : Too many automatic redirections were attempted.


&

An error occurred while retrieving package metadata for

I noticed there was a update for Visual Studio 2015 NuGet Package Manage for Visual Studio to version 3.1.60724.766 (from current 3.0.60624.657), so I downloaded and installed it.  Same errors.

Fix

In Visual Studio 2015.

Tools Menu -> NuGet Package Manager -> Package Manager Settings

Click Package Sources

Click + sign

Add the following:-

Name: something like NuGet v2

Source: https://www.nuget.org/api/v2/

Untick the current nuget.org so it should look like:-


And now you should be able to install NuGet packages

Asp.Net Forms Auth Login Page change globalization language culture

Using the standard Asp.Net Forms Authorization for an external web application which we needed to translate into another language other than English.  Changing all custom code is simple enough as we just use either local or global resources.  However what about changing the built in Asp.Net functionality like the login screen to another language.  Well good old Microsoft have thought of that and it is really simple.

First in your page make sure you have culture="auto" and uiculture="auto" as that will tell the code to make use of the browsers language settings for the user e.g.


Next is the simpler bit just install the .Net Language pack on the web server for the language you wish to use.  In this case I am wanting German so I pick the following for .Net 4.5:-

Microsoft .Net Framework 4.5 Language Pack

So now the login screen (showing out of the box screen so no formatting) in English is:-


And if my browser is set to German:-


Asp.Net Telerik RadAlert RadWindow change globalization language culture

Using Telerik excellent RadAlert within RadWindowManager in an Asp.Net Web Application and I need to translate my website into another language other than English.  So how do we change the RadAlert text on the buttons to be a different language depending on the users browser language settings?

For this I am using an Asp.Net Master Page and including both the RadWindowManager + RadScriptManager e.g.


Next create a Global Resources file for the default language (this case English) and also the language you are catering for (this case German):-


Change the MasterPage's code behind to associate the locatization file with the buttons:-


And that is it, so when a user runs your Web Application in a browser set to German it will now automatically change the buttons to the correct language for things like RadAlert.

Asp.Net Telerik RadGrid change globalization language culture

Using Telerik excellent RadGrid in an Asp.Net Web Application and need to translate my website into another language other than English.  In this case German so first download the resource file from Telerik currently located here:-

Global resources for RadGrid

Pop the file into App_GlobalResources folder or create one if you don't already have it:-


Here I am using the RadGrid.Main.resx (English) and RadGrid.Main.de.resx (German - all versions)

Now it does seem to pick up the language setting of the users browser settings so just do the switch in code (normally under Page_Load:-

if (!IsPostBack)

{

RadGrid.Culture = System.Globalization.CultureInfo.CurrentCulture

}

Setup Orchard CMS using Hosted Solution and Parallels Plesk Panel 9.5.5

Had Orchard CMS working lovely on my local machine (Windows 7 x64) and IIS.  I then wanted it moved to my hosted server and once I copied all the files over I found it was erroring.  Looking at the Orchard CMS documentation it seemed a few folders needed "Modify" permission.  OK this is fairly easy in IIS but how do I do it using my hosted solution.  Thankfully the Parallels Plesk Panel (9.5.5 I'm using) had the ability to do it.

Under Files
Click File Manager

Click Httpdocs (or where you have placed your Orchard CMS files)

Click the padlock next to app_data

Tick the "Replace permission entries on all child objects with entries shown here that apply to child objects.

Tick Modify/ Read & Execute/ List Folder contents/ Read/ Write

Click OK (this might take a while to complete).

You will also need to do the same for the Media/ Modules/ Themes folders.

However I still had issues and found out I needed to give permissions to the "bin" folder too

Just tick Read & Execute/ Read.

Then happily Orchard CMS works perfectly.