Celtic Coding Solutions Blog

Celtic Coding Solutions Blog - for everything computer related

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.

Windows Server Essentials Connector just hanging after entering account

Following on from my post:-

Connecting Windows 10 to Windows Server 2012 R2 Essentials

I found running the Windows Server Essentials Connector Configuration Wizard was hanging after I entered the account and password details.  No error messages appeared, just stopped working.

Looking at the connector logs:-

C:\ProgamData\Microsoft\Windows Server\Logs (ProgramData is a hidden folder but it exists on Windows 10).

I opened the most recent txt file in this case it was called ClientDeploy.txt and noticed lots of errors relating to:-

DNS_ERROR_RCODE_NO_ERROR

A bit strange as the browsers work.

Fix:-

The fix was a bit simple really, the DNS setting on the Wifi was set to Automatic and pointing to the routers IP lets say 192.168.1.1 however I needed to change the DNS setting to use the IP of the server lets say 192.168.1.2.  Re-running the Essentials Connector and it went straight through.  I changed the DNS setting back to be Automatic and everything works as it should.

Installing Intel Graphics driver on Windows Server 2012 R2 Essentials

Setting up a Desktop PC as a Windows Server 2012 R2 Essentials Server and not able to install the default Graphic card driver from HP.  The setup will not work either from the Intel website, but this is an old i7 processor using the onboard Intel HD 2000 graphics processors.

Fix:-

First you need to install the Windows Server Essentials Experience

Server Manager -> Manage (Tab) -> Add Roles and Features

Click through until "Server Roles" and then tick the "Windows Server Essentials Experience" (near the bottom)


Server might need a restart

Then download the driver direct from Intel here I am using the x64 bit driver from:-

Intel HD Graphics 2000 for 2nd Generation Intel Core Processors

Just run the setup and all should install correctly.

Getting WiFi to work on Windows Server 2012 R2 Essentials

So I setting up an old Desktop PC as a Windows 2012 R2 Essentials Server.  I wanted to use WiFi to set it up as I am not near a network port, but every time I enabled the disabled WiFi adapter it kept disabling itself again.  Even using a USB WiFi card didn't work so a little poke around and it was a simple fix to get working.

Fix:-

You need to install the Wireless Lan Service in Server Features.

So Run Server Manager -> Manage (Tab) -> Add Roles and Features

Click through the wizard until you get to Features Section and tick "Wireless Lan Service" (near the botttom).


Might need a restart.

OK but wait the WiFi adapter is still disabled.  Quick check in Services:-

Server Manager -> Tools (Tab) -> Services

and I noticed the WLAN AutoConfig was not started.  Start this and bingo you can now connect using WiFi.


Connecting Windows 10 to Windows Server 2012 R2 Essentials

So setting up a new home server using latest Windows Server 2012 R2 Essentials.  Tried to connect to the domain using the Server Web Connect e.g. http://[ServerName]/Connect and I can see the webpage and download the connection exe e.g. ComputerConnect[ServerName].exe but I get the following error when running it:

Windows Server Essentials Connector Configuration Wizard

An Unexpected error has occurred. To resolve this issue, contact the person responsible for you network.

Fix:-

Seems like the Web Connect doesn't yet work for Windows 10. So you need to install the KB from Microsoft and install it on your Windows 10.

Windows Server Essentials Connector for Windows Server 2012 R2

Once installed in Windows 10 you have a new App.

Click Start, All Apps

Scroll down to "Windows Server Essentials" and run "Windows Server Essentials Connector Configuration Wizard".  Then run through the setup and all should be good.


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

Visual Studio Performance And Diagnostics Service IISADMIN was not found on computer

Using Visual Studio 2013 and running the Debug - Performance and Diagnostics on my Windows 7 x64 PC I got the error:-

"Service IISADMIN was not found on computer"

I checked and I was running Visual Studio as Admin and IIS was running fine.

I did notice that I didn't have IIS 6 Management Compatibility enabled in the Windows Features.  So I turned these on and Performance and Diagnostics now works:-


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:-