'Loading Interop.Word.dll during runtime

I am currently working on a small console app that should have some sort of integration with Microsoft Word. I guess users might have different versions of Microsoft Office and thats why I decided to load interop asseblies during runtime (however I'm not sure that is right decision).

The next code throws an exception System.ArgumentNullException Value cannot be null. Arg_ParamName_Name. As I understand the problem is WordInterop.GetType("Application") returns null, however I do not understand why.

class Program
{
    static void Main(string[] args)
    {
        Assembly WordInterop = Assembly.LoadFrom("C:\\Windows\\assembly\\GAC_MSIL\\Microsoft.Office.Interop.Word\\15.0.0.0__71e9bce111e9429c\\Microsoft.Office.Interop.Word.dll");
        Assembly Office = Assembly.LoadFrom("C:\\Windows\\assembly\\GAC_MSIL\\office\\15.0.0.0__71e9bce111e9429c\\OFFICE.DLL");

        Type WordApp = WordInterop.GetType("Application");
        dynamic wordAppInst = Activator.CreateInstance(WordApp);
        wordAppInst.Visible = true;

    }
}


Solution 1:[1]

As I Found out the problem was in type name. Should be Microsoft.Office.Interop.Word.ApplicationClass instead of Application.

Solution 2:[2]

The following should work:

var wordAppType = Type.GetTypeFromProgID("Word.Application")
var wordAppInst = Activator.CreateInstance(wordAppType);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 KiNest
Solution 2 Axel Kemper