I am developing a real-time data server for Excel in c#.
Everything was doing fine until I started tried using classes from Assembly B into my XL Server (XLS).
When I instantiate "MyClass" (Assembly B) in the code of "XLS" class (Assembly A), and deploy/register the DLL, the call to "XLS" from an Excel App results in #N/A (i.e "something" went wrong)
Hence the question : How to use instances from Assembly B into Assembly A when deploying it via RegAsm to use into Excel as DLLs ?

public class XLS : Excel.IRtdServer
{
private MyClass MCHammer;
public int ServerStart(Excel.IRTDUpdateEvent cb)
{
try
{
int i = 0;
// When the following line is commented, the next one results in divide-by-zero exception (ok).
// but when left effective, I only get "#N/A" on Excel. So my guess is that this is blowing BEFORE Runtime.
MCHammer = new MyClass();
i = i / i; //Assert-line : Should blow divide-by-zero exception if executed
// This message is dropped to Excel for display
// When divide-by-zero line is commented AND NO instantiation of MyClass is made,
// This message is displayed in Excel (ie everything went fine)
XL_MESSAGE = "ALL COOL";
}
catch (Exception ex)
{
// This is dropped to excel for display when catch block is entered
// Only happens when "new MyClass()" line is commented
XL_MESSAGE = "EXCEPTION : " + ex.ToString();
}
}
}
I figured out Assembly B was x64 while Assembly A wad x86.
So Excel was dropping an invisible "Target Invocation Exception" (Bad Format etc...) behind the hoods
(I debugged stuff using a COM call simulation with a c# program sample)
More info on this on my other related question here and here
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