Sunday, 9 September 2018

FIXED: Umbraco 7, Could not load file or assembly MySql.Data

Today I was updating one of my websites running Umbraco 7.7.8 when I came across an issue with the MySql.Data dll.

All I was doing to the site was converting it multi-tennant which which in turn required a change in my SiteLayoutController to indicate the site root now started at the second level in the tree.

The change was tested locally ok but when I deployed to my live environment I started seeing the following error:

Could not load all types from "umbraco.DataLayer, Version=1.0.6582.14888, Culture=neutral, PublicKeyToken=null" due to LoaderExceptions, skipping:

. System.IO.FileLoadException: Could not load file or assembly 'MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)


. System.IO.FileLoadException: Could not load file or assembly 'MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)


. System.IO.FileLoadException: Could not load file or assembly 'MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)


. System.IO.FileLoadException: Could not load file or assembly 'MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)


. System.IO.FileLoadException: Could not load file or assembly 'MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)


Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.


I don't use MySQL and I didn't update any NuGet packages as part of the changes so not sure why this started happening.  The only way I was able to resolve it was to add the following in the <dependentAssembly> section of the web.config:

<dependentAssembly>
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.9.10.0" newVersion="6.9.10.0" />

</dependentAssembly>

I then tried to recreate the issue by removing the entry above and recycling the Application Pool... it loaded ok without the reference.  Not sure why the blip occurred but i'm back up and working again!

Friday, 27 May 2016

FIXED: ASP.NET MVC hybrid application 404 IIS7

So I recently upgraded one of my asp.net sites from a forms based website to a web application allowing a hybrid MVC approach.

I migrated the site without issue creating a new web application and copying in the required files and configuration.  Everything was good and my MVC areas all routed and worked as expected; I had done this before so was confident on the process.

Everything was good until I came to deploy the website on to a Windows 2008 R2 server running IIS7.5 (this configuration is not specific to the resolution I got though!).  The website started up ok, I could login ok and access the older forms based pages.  I then clicked on to a link that navigated to one of my MVC routes and was presented with a 404...

There are a number of similar issues I found on stackoverflow (http://stackoverflow.com/questions/16178821/mvc-4-application-giving-a-404-when-deployed) that were addressed by adding the following in to the web.config:
<modules runAllManagedModulesForAllRequests="true"/>
To eliminate the IIS being the issue I ran the site on a different server that was running another hybrid site without issue; same problem.

After comparing all the settings one I then moved on to the code and after many hours of searching found the culprit.

The application that was working had a published bin with all the regular dll's but the main difference I noticed was it had an App_global.asax reference where the failing app didn't:



For some reason my new application was not outputting these files which meant that MVC routes would not be configured at startup.  After playing around with the publish settings, cleaning and rebuilding the solution it started to include the required files.  Unfortunately its not an exact answer but will hopefully help some investigating the issue further.

Here is the settings I used in my publish that did eventually work:



Richard

Saturday, 21 November 2015

FIXED: Umbraco - Error loading MacroEngine Script

I have just had to go through the task of migrating a legacy Umbraco 4 site across to new web space.  

The site was a simple enough copy along with a backup and restore of the MySQL database. However when I came to run the website I got the message "Error loading MacroEngine Script (file:...)"

After a bit of digging I found two useful things; one to help with debugging and another to address the actual issue mentioned above. 

Assist with debugging

Within Ummbraco (prior to version 7 I believe) if you want to debug any issues you can update the following line within the web.config:



Once you have done this you can visit your problematic page with the following URL parameter on the end "?umbDebugShowTrace=true" and it will output trace information that may highlight any issues:



The issue that it actually highlighted was "There is no Lucene index in the folder..."

Fixing the issue

No after a little more digging this was simply resolved by going in to the App_Data folder within my site and emptying out all the folders within "TEMP/ExamineIndexes".  So I was left with the following empty folders beneath ExamineIndexes:



Tuesday, 17 February 2015

FIXED: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

I had this issue crop up while supporting an old website that when I came to publish the website in both Visual Studio 2012 and 2013 I would get the following error:

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.







After trying to set the "Target Location" setting here to a shortened path of "c:\wd" I still had the issue:




After some digging around I found that the fix was in the following file:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Transform\Microsoft.Web.Publishing.AspNetCompileMerge.targets

I changed:

<AspnetCompileMergeIntermediateOutputPath Condition="'$(AspnetCompileMergeIntermediateOutputPath)' == ''">$(IntermediateOutputPath)AspnetCompileMerge\</AspnetCompileMergeIntermediateOutputPath>

to 

 <AspnetCompileMergeIntermediateOutputPath Condition="'$(AspnetCompileMergeIntermediateOutputPath)' == ''">c:\sp\</AspnetCompileMergeIntermediateOutputPath>

The build then completed as expected

Friday, 5 October 2012

Using jQuery ValidationEngine in an ASP.NET - multiple forms

If you have found this post then chances are you are using the great ValidationEngine (jQuery-Validation-Engine) plugin with your ASP.NET application.

Everything work fantastic until you want two separate sets of validation on one page.  Within PHP you can simply wrap each logical sets of validation within their own <form> tags but this is not possible with asp.net.

Instead this is the approach I have used:

Within a set of script tags at the top of my page I put the following (I do have "var $j = jQuery.noConflict();" ):

     $j(document).ready(function () {
        $j("#btnSave").click(function (e) {
            var stopForm = false;
            if ($j("#txtForename").val() == "") {
                $j('#txtForename').validationEngine('showPrompt', 'You must enter a First name', 'error', 'topRight', true);
                stopForm = true;
            } else {
                $j('#txtForename').validationEngine('hide');
            }
   if (stopForm) {
                e.preventDefault();
            }
        });

  1. The above waits for the click event to be fired on the btnSave button.
  2. Sets a boolean variable to false
  3. Checks to see the that textbox object txtForename has a value
  4. If it doesn't that it attaches a popup notification and sets the stopForm variable to true
  5. If there is a value it makes sure that any previous popup that may have been added to the control is closed
  6. Finally the method checks to see if the stopForm variable is set to true, if it is then it calls the e.preventDefault() menthod which will ensure that the btnSave click event is not passed back to the server, allowing your user to address the highlighted issue.
I recommend having the ClientIDMode="Static" declaration on your page to ensure that jQuery can get expected access tot he controls in the DOM.

Open multiple excel files each in their own instance or window - Windows 7


If you’re a user of Microsoft Excel you’ll no doubt be familiar with the irritation of opening multiple spread sheets as they will open in the one instance of Excel. Meaning you have to flick from spread sheet to spread sheet.

Running the little Microsoft fix found here will make a small change to the way Excel opens spread sheets and force a new instance of Excel on each file you open. Meaning you can use aero snap and have one on each monitor / half of the screen.

Friday, 17 August 2012

jQuery Validationengine arrows not showing (ASP.NET)

On a recent project the customer wanted to display custom error messages.  To achieve this I had to write my custom validation method as opposed to using the css="validate[required]".

This was fine until I hit the issue where by when calling the showPrompt method as follows:

if ($j("#lstCustomerType").val() == "") {
             jQuery('#lstCustomerType').validationEngine('showPrompt', 'Please select a customer type', 'error', true);
     }
The validation message was showing but was not including the nice little arrow despite me passing the variable of "true" for this optional parameter.

The solution for this was to pass all the optional variables through to the method as follows:

             jQuery('#lstCustomerType').validationEngine('showPrompt', 'Please select a customer type', 'error', 'topRight', true);