Welcome to my Development Blog

Welcome to my new Development Blog.  This is a place for me to share Development news, tips and experiments.

Hopefully this site will become a useful source of information regarding Development, in various languages, using various applications.

Enabling OneDrive when some pesky admin has disabled it

On my corporate machine, it turns out that the powers that be decided to disable OneDrive.  I have a personal 1TB OneDrive account which I use for all manor of things, and I was not happy about this, so I set upon trying to find out a solution.

I found two useful things.

  • Local Group Policy Editor

    In the Local Group Policy Editor (Control Panel, Local Group Policy Editor, or just search for group in the Cortana Search Box), look for :

    Computer Configuration\Administrative Templates\Windows Components\OneDrive

    Find the key :

    Prevent the usage of OneDrive for File Storage

    And disable it.  If it is not configured, still disable it.

  • Windows Registry

    In the Registry Editor, look for :

    HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\OneDrive

    Find the keys (one, or both, depending on what appears) :

    DisableFileSyncNGSC
    DisableFileSync

    Change those values to 0.

 

Doing both of these may be enough to allow OneDrive to run again.  However, you may find that upon next boot, or if you connect to your corporate VPN, one or the other may have reverted back.

To try and fix this, within the Registry Editor, I have modified the Permissions on the Key Container (the folder : HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\OneDrive) and denied access to if for some of the users and groups.  I think it has worked, but time will tell I suppose.

 

Easy access to your TFS/GIT folder

This post describes something that I always do when setting up a new PC with Visual Studio.  Its only a minor thing, but it makes all the difference to me 🙂

The amount of times I open up Windows Explorer to navigate to my TFS folder in one day is quite a lot, and I follow these steps to make life a bit easier, especially on Windows 10.

  1. Right click on your main TFS folder and select Properties.

  2. Go to the customise tab, and select Change Icon.

  3. Click Browse and find an appropriate icon file, or, in my case, navigate to your Visual Studio folder and select DevEnv.exe  and select the appropriate icon.
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe

  4. Hit Apply, and your TFS folder will now have a nice new icon.  To make it easier to access, you can also right click it and select Pin to Quick access.

    This will mean it will always show up at the top left of Windows Explorer in your Quick access panel.

This can be applied to any folder of course, not just your TFS folder, as long as you have an appropriate icon.

One thing I would say though, don’t go customising all of your folders with nice new icons.  I’m not sure, but I guess it may have an effect on performance.  It probably caches the icons, but just in case, be careful.

 

 

Removing a Code Analyser from your machine during development

This post is just a quick tip for anyone that may be developing a Code Analyser withing Visual Studio using the Roslyn Compiler.

I got in a position where I was developing a code analyser using Visual Studio and the Roslyn SDK, I abandoned a project that was broken, but, whenever I launched Visual Studio afterwards, the analysis package would still be loaded and start crashing all over the place.

I really struggled to find a standard way of removing it from my machine (there probably is a way, but I could not find it), until I discovered this.

If you navigate to the following folder, you can simply delete the appropriate folder and it will be gone forever (I hope) :).


C:\Users\{username}\AppData\Local\Microsoft\VisualStudio\15.0_a85fe1c6Roslyn\Extensions\{user}

The actual file path may differ depending on versions of SDK and VS, but I am sure you can work it out 🙂

CRM Utilities for Visual Studio – Update to menus, and class generation options

Today I have released a new version of my CRM Utilities for Visual Studio 2017.

Good usefull LinqPad post (external)

Found this post in my twitter feed and thought I would share it.

Describes using LinqPad as a quick AWS dashboard.

Debugging Visual Studio Extensions

Whenever I set up a new machine, re-install Visual Studio, or simply re-download my Visual Studio Extensions from TFS, I always have to remember how to set up the environment so that I can debug the extension from within Visual Studio.

To be able to do this, here is the solution, in case you were wondering.

Problem

When hitting F5, or running/debugging the VSIX extension, you get a message in Visual Studio, something like:

a project with output type of class library cannot be started directly

Solution

In Visual Studio, in the project properties for your VSIX extension, the following options tell Visual Studio that when building the project, the VSIX compiled executable is created so that it can be run directly from Visual Studio.

To be able to run an “experimental” instance of Visual Studio which will then allow you to debug and set breakpoints in the original Visual Studio Instance that you have run the project from, you need to set the following options in the Debug tab of the Project Properties.

Note that the Start external program box is actually pointing to:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe

 

This allows you to debug the extension by pressing F5.  A new clean instance of Visual Studio will launch and allow you to test your extension.

CRM Utilities for Visual Studio – Generating Entity Classes

Most CRM Developers either use, or have at least heard of CrmSvcUtil for generating early bound classes for developing code and using the resulting classes to manipulate CRM data.  I personally do not like working with early bound entities as the resulting class files are huge, and I personally prefer working with the standard Entity Framework for creating and updating entities, and for Linq queries.

Often, I use some helper class libraries that I can use to represent the custom entity names and attributes, so that they can be referenced in code and provide a degree of separation from the actual Schema names and to make code easier to write, and support Intelli-sense.

Something like the code sample below:


public static class Contact
{
    public static const string EntityName = "contact";
    public static const string Name = "fullname";
}

This would then allow you to do the following:

public void createContact()
{
    Entity contact = new Entity(Contact.EntityName);
    contact[Contact.Name] = "Joe Blogs";
    service.Create(contact);
}

I was offered a suggestion by a fellow developer that wouldn’t it be good if my CRM Utilities for Visual Studio allowed you to generate this kind of Class file automatically.  Well, I thought it was a brilliant idea, and so thanks to the wonderful gentleman  of XRTSoft, here it is.

Its split into two options, one to generate classes for your Custom Entities, and one to do the Standard CRM entities.

The resulting file will look something like this:

Notice that for each Entity, it will add the Logical Name, Primary ID Attribute, and the Primary Name Attribute as standard, and then all of the attributes as well.  It will also add sub classes for any Option Sets to allow you to reference specific Option Set Values without having to look them up in CRM.

 

Download
Please note this feature is only available in the Visual Studio 2017 version. This version may still install on VS2015, although I have not personally tested it.