.Net Assembly Registration&依赖性问题

时间:2011-11-17 11:41:03

标签: c# .net excel

我正在用c#开发Excel的实时数据服务器 一切都很好,直到我开始 尝试使用程序集B中的类进入我的XL服务器(XLS)。
当我在“XLS”类(程序集A )的代码中实例化“MyClass”(程序集B ),并部署/注册DLL时,调用从Excel应用程序“XLS”导致#N / A(即“某事”出错)

因此问题:如何在通过RegAsm部署它时将程序集B中的实例用于程序集A以用作Excel作为DLL?

Architecture

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(); 
        }
    }
}

1 个答案:

答案 0 :(得分:1)

我发现装配B是x64而装配A是x86 所以Excel在引擎盖后面放弃了一个看不见的“目标调用异常”(Bad Format等...)
(我使用带有c#程序样本的COM调用模拟调试了东西)

关于我的其他相关问题herehere

的更多信息