Week 35 roundup

Last week recap and links:

Image courtesy of kanate / FreeDigitalPhotos.net

Image courtesy of kanate / FreeDigitalPhotos.net

What are your best reads this week? Leave them in the comments below.

Posted in Uncategorized | Tagged , , , , | Leave a comment

Get Spreadsheetlight working

Spreadsheetlight is a dotnet library for creating Excel documents with all it’s wonderful features. The Spreadsheetlight nuget has no dependencies on nuget packages, but does have a dependency on Open XML SDK 2.0. This can be installed with the DocumentFormat.OpenXml 1.0.0 nuget.

But after a while everything stopped working, because you tried updating the DocumentFormat.OpenXml to the latest version 2.5.0.

An unhandled exception of type ‘System.TypeLoadException’ occurred.
Additional information: Could not load type ‘DocumentFormat.OpenXml.Spreadsheet.SmartTags’ from assembly ‘DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’.

or

An unhandled exception of type ‘System.IO.FileLoadException’ occurred.
Additional information: Could not load file or assembly ‘DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference.

Solution

  1. Revert back to DocumentFormat.OpenXml version 1.0.0
    Install-Package DocumentFormat.OpenXml -Version 1.0.0
    
  2. Remove the assemblyBinding from the app.config
    <configuration>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <!-- Remove dependentAssembly for DocumentFormant.OpenXml -->
          <dependentAssembly>
            <assemblyIdentity name="DocumentFormat.OpenXml" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-2.5.5631.0" newVersion="2.5.5631.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>
    
Posted in Development | Tagged , , , , | 18 Comments

Week 34 roundup

Last week recap and links:

Image courtesy of kanate / FreeDigitalPhotos.net

Image courtesy of kanate / FreeDigitalPhotos.net

What are your best reads this week? Leave them in the comments below.

Posted in Uncategorized | Tagged , , , , , , | Leave a comment

Azurewebsites backup with webjobs

We have some low traffic websites hosted in azure. Backups are important to us, but only available on the Standard web hosting plan. So we created a webjob to do it.

azurewebsite backup only available in Standard web hosting plan

Following Eduardo Laureano‘s post the plumbing was soon done. We modified the code to upload a zipfile and we’re done. Some of the changes in code block below.

// format filename as AzureBackup would
string backupName = string.Format("{0}_{1}.zip", 
            websiteName, 
            DateTime.Now.ToString("yyyyMMddHHmm"));
string zipFile = Path.Combine(Path.GetTempPath(), backupName);
// ZipFile is in System.IO.Compression.FileSystem
ZipFile.CreateFromDirectory(DIRECTORY_TO_BACKUP, zipFile);
// Create block blob for zipfile upload
CloudBlockBlob blockBlob = 
    blobContainer.GetBlockBlobReference(backupName);
using (var fileStream = File.OpenRead(zipFile)) {
    blockBlob.UploadFromStream(fileStream);
}
// Clean up temporary local file
File.Delete(zipFile);

The webjobs is scheduled to run every week. Now we get weekly backups of our files. Not as nice as Microsoft does it with fancy restore, database include and xml listing of files, but it suits our needs.

References

Posted in Development | Tagged , , | Leave a comment

Week roundup 33

Last week recap and links:

Image courtesy of kanate / FreeDigitalPhotos.net

Image courtesy of kanate / FreeDigitalPhotos.net

What are your best reads this week? Leave them in the comments below.

Posted in Uncategorized | Tagged , , , | Leave a comment