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
Excel, among others, is reached via a COM interop type. It is an interface, decorated with GUID's and stuff. When you use it, it uses COM to communicate with a running Excel application. So your reference is not Excel itself, but merely a thin COM communication layer.
COM interop types may be embedded into your assembly, that seems to be the case here. You can specify that as a property of the assembly reference in your project.
See for example: http://msdn.microsoft.com/en-us/library/dd997297%28v=vs.110%29.aspx or http://msdn.microsoft.com/en-us/library/ee317478.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With