Celtic Coding Solutions Blog

Celtic Coding Solutions Blog - for everything computer related

Umbraco Exception Details - System.InvalidCastException Specified cast is not valid

Whilst trying to use Umazel Starter Kit on the latest version of Umbraco 7.6.3 I was getting the following Asp.Net Error:-

Exception Details: System.InvalidCastException: Specified cast is not valid.
switch ((int)currSection.TitleSize)

e.g.

Fix

Open umbracoSettings.config file usual in the Config directory of Umbraco.

Find:-

<EnablePropertyValueConverters>true</EnablePropertyValueConverters>

and change to 

<EnablePropertyValueConverters>false</EnablePropertyValueConverters>

Umbraco 7.6 Compiler error Type exists in both Temporary Asp.Net dll file

Whilst trying to use Umazel Starter Kit on the latest version of Umbraco 7.6.3 I was getting the following Asp.Net Error:-

Compiler Error Message: CS0433: The type 'Umbraco.Web.PublishedContentModels.Pagehome' exists in both 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\3c224001\fb5ad5e1\App_Web_all.generated.cs.8f9494c4.zr84uuak.dll' and 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\3c224001\fb5ad5e1\assembly\dl3\4e0eb2b9\6e2d66f5_3ae0d201\Umbraco.Web.PublishedContentModels.DLL'

e.g.

This is odd as the start kit works fine in version 7.5 of Umbraco.

Fix

Open with Web.Config for Umbraco in default Directory and find (usual under appSettings):-

<add key="Umbraco.ModelsBuilder.Enable" value="PureLive" />

change the value from ="PureLive" to ="Dll" e.g.

<add key="Umbraco.ModelsBuilder.Enable" value="Dll" />

Umbraco Redirect 404 errors to default home page

I needed to redirect 404 not found errors to the default home page in Umbraco.  Usually in Asp.Net you can just set the web.config and set an error statuscode to do something.  However in Umbraco it uses its own internal 404 page which has a neater way of redirecting to a page you specify.

First login to your Umbraco site.  Go the page you want the 404 to be redirected to, here I am using my Home Page (default page).

Notice the URL and the last 4 digits (1012).  Remember this bit.

Open the UmbracoSettings.config - this is usually in the Umbraco Config directory.  Find the <errors> section and specifically <error404> e.g.

Then enter the URL ID as seen above and now any 404's will be redirected to your home page (but the url will still show as the incorrect path).

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.

Microsoft SharePoint 2016 Prerequisites Installation on Windows Server 2012 r2

Tried to install a fresh copy of Microsoft SharePoint on Windows Server 2012 r2 and had the following prerequisite failed:-

OK so looks like we need to install a few things:-

Install Windows Identity Foundation
Open Powershell (as Administrator)
Add-WindowsFeature windows-identity-foundation

Reboot

Install the Microsoft Identity Extensions
http://download.microsoft.com/download/0/1/D/01D06854-CA0C-46F1-ADBA-EBF86010DCC6/r2/MicrosoftIdentityExtensions-64.msi

Install Microsoft Sync Framework Runtime v1.0 SP1 (x64)
http://download.microsoft.com/download/E/0/0/E0060D8F-2354-4871-9596-DC78538799CC/Synchronization.msi

Windows Server AppFabric
Download the Windows Server AppFabric exe and save it to your Server. Then run the PreRequisiteInstaller from the SharePoint 2016 ISO (CD) using the following command line (as Administrator):-
prerequisiteinstaller.exe /appFabric:[Dir where you saved the AppFabric exe]\WindowsServerAppFabricSetup_x64.exe

Note- it will do a reboot after installation.

Install Microsoft ODBC Driver 11 for SQL Server
https://download.microsoft.com/download/5/7/2/57249A3A-19D6-4901-ACCE-80924ABEB267/ENU/x64/msodbcsql.msi

Install Microsoft WCF Data Services 5.6 (rename this download to WcfDataServices56.exe)
http://download.microsoft.com/download/1/C/A/1CAA41C7-88B9-42D6-9E11-3C655656DAB1/WcfDataServices.exe

Install Microsoft Information Protection and Control Client (MSIPC)
http://download.microsoft.com/download/9/1/D/91DA8796-BE1D-46AF-8489-663AB7811517/setup_msipc_x64.msi

Install IIS 6 Management Compatibility component
Open PowerShell (as Administrator)
Add-WindowsFeature Web-WMI

Reboot

The following maybe needed, but it was not for me.
CU 1 for AppFabric 1.1 (KB2671763):
http://download.microsoft.com/download/7/B/5/7B51D8D1-20FD-4BF0-87C7-4714F5A1C313/AppFabric1.1-RTM-KB2671763-x64-ENU.exe

Then try installing SharePoint 2016 again and all should be well.

Remove Skype Preview from Windows 10

I use Skype for my calls and so download and install the application on my PCs.  However on Windows 10 it pre-installs Skype Preview which I found takes over the normal Skype application and therefore doesn't allow me to send/receive calls.  Simplest solution I found was to uninstall Skype Preview using Powershell.  

Open PowerShell as administrator and run:-

Get-AppxPackage *skypeapp* | Remove-AppxPackage

Install SSL Cert from GoDaddy on IIS 8 in Windows Server 2012 r2

1) Create Cert Request
Open Internet Information Services (IIS) Manager.
Click the Server
Under IIS grouping find “Server Certificated” and double click it:-

Under Actions (right hand side) click “Create Certificate Request…”

Enter in some details e.g.

Click Next

Select Bit Length 2048

Create an output file – click finish.

2) Import to Go Daddy

Open the Text File that you created above and you will have a load of characters – this is the key.
In Go Daddy purchase the SSL Certificate e.g. *.MyCompany.com or click Manage if you already have one.
In the next screen click the ReKey & Manage button:-

Expand Re-Key certificate + tab and you will see:-

Copy/Paste the text from the file you created above and click Save. Then click the “Submit All Saved Changes”
Then wait a few minutes whilst it is processed.
Once Complete click the Download button and save the zip file.

3) Install on the Server

Follow the instructions on the Go Daddy WebSite at:-
IIS8 Install a Certificate
But the most important bit is to reboot the server otherwise the Certificate will not work.

Note
If you find that your Certificate seems to disappear when you “Complete Certificate Request…” this is because your certificate hasn’t been correctly keyed for the server so please re-do Step 2 above.

 

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.

Adding Windows 10 PC to a domain using VPN

As a remote worker I needed to join my newly built Windows 10 PC to the domain using Windows VPN.

  • First login to the machine as a local admin
  • Setup a VPN to the company and connect
  • Join the PC to the domain
  • Reboot
  • Log back in as local administator
  • Connect VPN again, switch account
  • Try logging on with your domain account and you will probably see this error:-

The Group Policy Client service failed the sign-in.  The universal unique identifier (UUID) type is not supported.


Fix

If you log back into the local administator account you will notice the VPN has been disconnected which did not happen in Windows 7.  The fix is simply to create a VPN that stays connected when you switch account.

So login again as the local administrator and run powershell as administator, then enter:-

Add-VpnConnection -Name NAMEOFVPN -ServerAddress VPNADDRESS -AllUserConnection $true -SplitTunneling $true -AuthenticationMethod MSChapv2 -TunnelType Automatic -EncryptionLevel Required -PassThru

Connect to the VPN which using NAMEOFVPN you used in the PS Script.

Switch accounts and try to login as a domain user and you will not see the error again.