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)



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



and change to 


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'


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


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).

Pyramid Analytics - Problem exporting content

Using Pyramid Analytics and trying to export content of the report (or just export the report to PDF)

After I clicked the "Click here to get file" I got the following error:-

System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Basic realm="SERVERNAME"'. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized. at System.Net.HttpWebRequest.GetResponse() at ......

This seemed strange as everything else on the site was working fine.


The problem was with a setting on the IIS that was running the site.

Open IIS, find BIOffice6 under the Sites.  Click Authentication and make sure everything is Disabled apart from Asp.Net Impersonation and Basic Authentication.  For some reason my setup had Windows Authentication enabled which was causing the error.  E.g you settings should look like:-

Asp.Net controls not keeping state on postback

Upgraded an Asp.Net project from Visual Studio 2013 to Visual Studio 2015 and then updated Telerik Controls from Version 2015.1.401.45 to 2015.2.826.45 and noticed none of my dropdowns, treeview controls where keeping state on postbacks.  I was binding data to these controls as per normal, but on postbacks they where losing state, so the dropdowns where empty and the chosen items where obviously not being kept.

Checked my Web.Config and I still had sessionstate active:-

<sessionState mode="InProc" cookieless="false" timeout="30" />


After much scratching of head I had another look at web.config and compared against a version in source control that was working and noticed this little gem:-

<pages enableViewState="false">

      <controls><add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" /></controls>


So looks like the upgrade either with telerik or Visual Studio added:-


After removing this my Asp.Net code worked again - phew!

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]


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


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

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


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.


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