Skip to content

Change the network interface of a VM in Azure

I got help here:

What to do:

  1. Dissociate your public ip from your old network interface. Choose the public ip and click “Dissociate”.
  2. Create your new network interface.
  3. Then associate the public ip with the new network interface.
  4. Get the resource id of both the old and new network interface in Azure portal: Choose the Network interface -> Properties -> RESOURCE ID
  5. Then run the following Azure-PowerShell-command:

Get-AzureRMVM -ResourceGroupName [RESOURCE-GROUP] -Name [MACHINE-NAME] | Remove-AzureRmVMNetworkInterface -Id “[RESOURCE-ID-OLD-NI]” | Add-AzureRmVMNetworkInterface -Id “[RESOURCE-ID-OLD-NI]” | Update-AzureRmVM

Advertisements

An item with the same key has already been added

I am working on a Visual Studio VSIX-solution. When i tried to open the “source.extension.vsixmanifest” I got the error “An item with the same key has already been added”. After a while (some googling) I realized that I had projects in my solution with the same name. My solution structure:

  • Solution ‘VisualStudio-Templates’ (9 projects)
    • .Global
    • Assemblies
      • Common
        • Common
        • IntegrationTests
        • UnitTests
      • Templating
        • IntegrationTests
        • Templating
        • UnitTests
    • Templates
    • Package

I renamed the test-projects so the structure is this:

  • Solution ‘VisualStudio-Templates’ (9 projects)
    • .Global
    • Assemblies
      • Common
        • Common
        • Common.IntegrationTests
        • Common.UnitTests
      • Templating
        • Templating
        • Templating.IntegrationTests
        • Templating.UnitTests
    • Templates
    • Package

This solved the problem.

Missing XFormFolders in EPiServer

Last week I had problems with missing xform-folders. I do not know if it has something to do with upgrading to EPiServer 10. It’s after upgrading to 10 I stepped into the problem.

When you click on a xform-property you get to the xform-selector, ~/EPiServer/CMS/edit/XFormSelect.aspx?form=THE-FORM-GUID. Choosing the folder-option “All forms” made it crash with a NullReferenceException. It turned out that som xforms belonged to xform-folders that no longer existed.

Looking at EPiServer.XForms.XFormFolder with a decompiler gives that the root-folder guid is 89ED3722-9625-4de2-BEC6-ECDD162DCBDC. So I wrote the following SQL to find missing XFormFolders:

DECLARE @Guid UniqueIdentifier = '89ED3722-9625-4de2-BEC6-ECDD162DCBDC';
 
SELECT
	DISTINCT(Guid01)
FROM
	tblSystemBigTable
WHERE
	StoreName = 'XForms' AND
	Guid01 <> @Guid AND
	Guid01 NOT IN (SELECT [Guid] FROM tblBigTableIdentity WHERE StoreName = 'XFormFolders')
ORDER BY
	Guid01;

And to upgrade all references from the missing folders to the root-folder i used:

DECLARE @Guid UniqueIdentifier = '89ED3722-9625-4de2-BEC6-ECDD162DCBDC';
 
UPDATE
	tblSystemBigTable
SET
	Guid01 = @Guid
WHERE
	StoreName = 'XForms' AND
	Guid01 <> @Guid AND
	Guid01 NOT IN (SELECT [Guid] FROM tblBigTableIdentity WHERE StoreName = 'XFormFolders');

After that my problem was solved.

Reinstall NuGet-packages

When you, for example, change the target framework for your Visual Studio project/projects you may need to reinstall your NuGet-packages.

Links:

Examples:

  • Update-Package -Reinstall (reinstalls all packages in the solution)
  • Update-Package -Reinstall -Project Company.Function (or -ProjectName, reinstalls all packages in the specified project)
  • Update-Package -Reinstall MyPackage (reinstalls the package “MyPackage” in the whole solution)

Some other parameters:

  • -IgnoreDependencies (skips updating any of the package’s dependencies)
  • -WhatIf (shows what would happen when running the command without actually performing the update)

Restore a SQL Server Backup to LocalDB

Found help here:

Thank you Rob!

  1. Open the “SQL Server Object Explorer” window in Visual Studio
  2. Right-click on the “(LocalDB)\MSSQLLocalDB”-node and choose “New Query…”
  3. The “master” database should be selected one
  4. Run the following query (the query will only present information):
            RESTORE FILELISTONLY
            FROM DISK = ‘D:\MyDatabase.bak’;
  5. In the result use the names in the LogicalName-column
            MyDatabase (mdf)
            MyDatabase_log (ldf)
  6. Run the following query:
            RESTORE DATABASE MyDatabase
            FROM DISK = ‘D:\MyDatabase.bak’
            WITH MOVE ‘MyDatabase’ TO ‘D:\MyDatabase.mdf’,
            MOVE ‘MyDatabase_log’ TO ‘D:\MyDatabase.ldf’,
            REPLACE;

System.Web.Optimization: Issues using IItemTransform when optimizations are enabled

I have a project where I use Web Essentials/Web Compiler to generate css from less. The default setting in Web Compiler is to create *.min.css files.

So in my project I have:

  • Style/Main.less
  • Style/Main.css
  • Style/Main.min.css

If I have these lines in my bundle configuration method:

  • BundleTable.EnableOptimizations = false;
  • BundleTable.Bundles.Add(new StyleBundle(“~/Style-bundle”).Include(“~/Style/Main.css”, new CssRewriteUrlTransform()));

CssRewriteUrlTransform will be called

If I have these lines in my bundle configuration method:

  • BundleTable.EnableOptimizations = true
  • BundleTable.Bundles.Add(new StyleBundle(“~/Style-bundle”).Include(“~/Style/Main.css”, new CssRewriteUrlTransform()));

CssRewriteUrlTransform will NOT be called

I want CssRewriteUrlTransform to be called when optimizations are enabled. It’s then I really want it.

I googled and found this:

The solution there works. I started to search in Reflector for “min” and found this property:

  • BundleTable.Bundles.FileExtensionReplacementList

So if I have these lines in my bundle configuration method:

  • BundleTable.EnableOptimizations = true;
  • BundleTable.Bundles.FileExtensionReplacementList.Clear();
  • BundleTable.Bundles.Add(new StyleBundle(“~/Style-bundle”).Include(“~/Style/Main.css”, new CssRewriteUrlTransform()));

CssRewriteUrlTransform will be called

Fonts not showing up in IE 11 on Windows 10

On a site using glyphicons the fonts did not show up in IE 11 on Windows 10. When I looked in the console in F12-developmenttools I found these entries:

  • CSS3111: @font-face påträffade ett okänt fel.
    fontawesome-webfont.woff
  • CSS3114: @font-face misslyckades med kontrollen av OpenType-inbäddningsbehörighet. Behörigheten måste vara Installable.
    glyphicons-halflings-regular.ttf

I searched and found this:

leading to this

I also found this:

In the Local Group Policy Editor (gpedit.msc) you can set this option. For me it was a group-policy set in the domain. Changing the setting requires a restart.

The setting on my swedish machine I found here in the Local Group Policy editor:

Datorkonfiguration/Administrativa mallar/System/Åtgärdsalternativ – Blockering av teckensnitt som inte är betrodda

“Block Untrusted Fonts” is something to search for.