August 10, 2012

Mapping SkyDrive, DropBox etc. folder to drive

This post is not related to MS CRM in any way, but it might come handy so I thought it’s worth sharing.

When installing cloud based storage like SkyDrive or DropBox you get a nice link in the Favorites section of Windows Explorer. Something like this:

This works very nice until the application shows you the “modern” save or open file dialog.

But what happens if an application is “legacy” or for some different reasons (I’m guessing Java) is using the older versions of the dialogs. You get something like this (example is from Adobe Reader X):

Navigating to your cloud based storage gets a little annoying. You have to click [Computer], [C],  [Users], [USER_NAME], [SkyDrive]. That’s 5 clicks just to get to the stupid folder. Someone could say that you only need to type in "%UserProfile%\SkyDrive, but lets be honest – that’s not something most of us think of in such situations (also moving the hand away from the mouse in order to type is quite annoying Smile ).

Wouldn’t it be nice to be able to map such folders to a drive letter? That way it’s only 2 clicks away.

The solution is quite easy – a windows command called subst. The syntax is as follows:
C:\Users\kowgli>subst /?
Associates a path with a drive letter.

SUBST [drive1: [drive2:]path]
SUBST drive1: /D

  drive1:        Specifies a virtual drive to which you want to assign a path.
  [drive2:]path  Specifies a physical drive and path you want to assign to
                 a virtual drive.
  /D             Deletes a substituted (virtual) drive.

Type SUBST with no parameters to display a list of current virtual drives.

So in my case just typing in subst Z: C:\Users\kowgli\SkyDrive almost solves the problem. The problem is this is not persistent across system reboots. In order to overcome this one of the simple solutions is to ensure the command gets executed each time the system start – read HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run


Adding the command to that registry area solves the problem. And now our folder is permanently mapped to a drive, which saves us 3 clicks a couple of times per day Open-mouthed smile

I know for some people this problem is trivial, but still … I thought it would be nice to share.


August 9, 2012

CRM 2011 plugin registration error “Inheritance security rules violated by type”.

When trying to register a plugin using an external dll ILMerged into it I came across the following error:

Unhandled Exception: System.TypeLoadException: Inheritance security rules violated by type: 'XXX.YYY.ZZZ.Plugins.ABC'. Derived types must either match the security accessibility of the base type or be less accessible.
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()

I remembered I had this issue before. The reason is that some legacy external libraries don’t follow .NET 4.0 security rules. The solution it actually quite simple – revert back to .NET 2.0 security. Simply add the following attribute anywhere inside you’re code (after the using statements):

[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]