gpt4 book ai didi

c# - .Net 程序集注册和依赖问题

转载 作者:行者123 更新时间:2023-11-30 18:02:22 24 4
gpt4 key购买 nike

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

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

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

最佳答案

我发现程序集 B 是 x64,而程序集 A 是 x86。
所以 Excel 在幕后隐藏了一个不可见的“目标调用异常”(格式错误等...)
(我使用带有 C# 程序示例的 COM 调用模拟来调试东西)

有关我的其他相关问题的更多信息 herehere

关于c# - .Net 程序集注册和依赖问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8166503/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com