type.Assembly gives wrong assembly?

Viewed 158

I want to create a reference to the Excel assembly and use this code:

[Test]
public void ExcelTest()
{
    Assembly current = this.GetType().Assembly;
    Assembly excel = typeof(Microsoft.Office.Interop.Excel.Workbook).Assembly;
    Assert.AreEqual(current.FullName, excel.FullName); // Why is excel the same as current assembly?
}

[Test]
public void MscorlibTest()
{
    Assembly mscorlib = typeof(string).Assembly;
    Assert.IsTrue(mscorlib.FullName.StartsWith("mscorlib"));

    Assembly current = this.GetType().Assembly;
    Assert.AreNotEqual(mscorlib.FullName,current.FullName); // As expected
}

Why is excel the same as my current assembly?

What is a nice way to get the Excel assembly?

Could not find my dumb when reading the docs

1 Answers
Related