我正在用c#开发Excel的实时数据服务器
一切都很好,直到我开始 尝试使用程序集B中的类进入我的XL服务器(XLS)。
当我在“XLS”类(程序集A )的代码中实例化“MyClass”(程序集B ),并部署/注册DLL时,调用从Excel应用程序“XLS”导致#N / A(即“某事”出错)
因此问题:如何在通过RegAsm部署它时将程序集B中的实例用于程序集A以用作Excel作为DLL?
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();
}
}
}