调用从Excel RTD服务器时异常 [英] Exception when calling RTD server from Excel

查看:3599
本文介绍了调用从Excel RTD服务器时异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了使用Visual Studio 2010的Excel VSTO插件和已经设法解决大多数的微软障碍扔进义开发商的路径后,我终于不得不承认失败。

I wrote a VSTO Excel addin using Visual Studio 2010 and after having managed to work around most of the obstacles Microsoft throws into the path of the righteous developer, I finally have to admit defeat.

我的项目包含一些控件的功能区,自定义任务窗格,可让用户通过一个RESTful接口和RTD服务器,让他们把这个数据在搜索数据库他们的工作表。到目前为止,一切都...好,痛苦,我想:很多与互操作,ComVisibility和应用程序域(!有什么了不起的想法),我现在的状态如下:

My project contains a Ribbon with some controls, a custom task pane that allows users to search a database via a RESTful interface and a RTD server that lets them put this data in their worksheets. So far, so ... well, painful, I guess: After a lot of struggle with Interop, ComVisibility and AppDomains (what a great idea!), my current status is as follows.

在工作表,我称之为包装功能RTD像这样(剪断):

In the worksheets, I call a wrapper function for RTD like this (snipped):

Public Function call(value as String)
    Dim addin as Office.ComAddIn
    Set addin = Application.ComAddIns("MyAddin")
    addin.Object.RTD(value)
End Function

这是(部分)的插件类:

This is (part of) the addin class:

namespace Some
{
   [Guid("...")]
   [ComVisibleAttribute(true)]
   [ClassInterface(ClassInterfaceType.AutoDual)]
   public class MyAddin {
      [snip]

      public String RTD(String value)
      {
         String returner = null;
         try
         {
            returner = Globals.ThisAddin.Application.WorksheetFunction.RTD(SERVERID, "", value);
         }
         catch(COMException ce) 
         {
            returner = ce.StackTrace;
         }
         return returner;
      }
   }
}

和的相关部分RTD服务器类:

And the relevant part of the RTD Server class:

namespace Some 
{
   [Guid("...")]
   [ComVisibleAttribute(true)]
   [ClassInterface(ClassInterfaceType.AutoDual)]
   [ProgId("MyRTDServer")]

   public class Server : Excel.IRtdServer
   {
      [snip]
   }
}

在调试模式我:


  1. 创建一个空的新的工作簿

  2. 添加一个= RTD(。 ..)公式的单元格

  3. 的包装函数调用添加=调用(...)到细胞

  4. 保存工作簿

  5. 打开工作簿

  6. 停止调试,并开始再次

  7. 打开工作簿

  1. Create a, empty new workbook
  2. Add an "=RTD(...)" formula to a cell
  3. Add a wrapper function call "=call(...)" to a cell
  4. Save the workbook
  5. Open the workbook
  6. Stop Debugging and start it again
  7. Open the workbook

我注意到:


  • 在3,一切工作正常

  • 在5,一切工作正常

  • 在7,重新计算我的单元格时,我收到了无法获取RTD财产在3单元的WorksheetFunction类除外)和#N / A 在2单元)。不过,我可以看到主题的RTD服务器中注册,一旦数据可用,异常被替换为正确的数据。另外,如果我做的不可以重新计算细胞,它们显示保存的值,而一旦数据可用,那么正确更新检索到的值。

  • At 3, everything works fine
  • At 5, everything works fine
  • At 7, when recalculating my cells, I get a Unable to get the RTD property of the WorksheetFunction class exception in the cell of 3) and #N/A in the cell of 2). However, I can see that the topics are registered in the RTD server and as soon as the data is available, the exception is replaced with the correct data. Also, if I do NOT recalculate the cells, they display the saved value and then correctly update to the retrieved value once the data is available.

如果在部署模式中,我观察到:

If in deployed mode, I observe:


  • 在2,我获得#N / A

  • 在3,我收到了无法获取WorksheetFunction的RTD财产类例外

  • At 2, I get #N/A
  • At 3, I get a Unable to get the RTD property of the WorksheetFunction class exception

任何帮助,好吗? (

编辑:

测试相同的步骤一个非常基本的RTD在一个空白的加载项项目的服务器精确地显示出相同的结果:加载的excel文件显示#N / A 如果服务器可用的数据之前RTD-公式重新计算$。 b $ b口想询问:WTF

Testing the same procedure with a very basic RTD server in a blank Addin project shows exactly the same results: a loaded excel file displays #N/A if an RTD-formula is recalculated before the server has the data available. I would like to inquire: WTF?

干杯,

推荐答案

在'无法获取RTD财产......的错误仅仅是Excel对象模型的说法有一个在函数调用错误的方法。

The 'Unable to get the RTD property....' error is just the Excel object model's way of saying there was an error in the function call.

请问您RTD服务器对您的外接其余任何依赖关系?事实上,2)部署失败的时候,使它看起来像RTD服务器需要运行之前愉快一些其他位被初始化。在VSTO外接的方式放在一起,你的装配很可能是为RTD服务器,并为COM加载项,并在有问题的情况下,RTD实例首次加载完全分开装。

Does your RTD server have any dependencies on the rest of your add-in? The fact that 2) fails when deployed, makes it look like the RTD server needs some other bits to be initialized before it runs happily. The way the VSTO add-in is put together, your assembly is likely to be loaded totally separately for the RTD server and for the COM add-in, and in your problematic cases the RTD instance is loaded first.

也许你可以用一个样品RTD服务器,而不是你自己的测试,只是为了确认该错误是存在的,而不是在包装或VSTO外接其他地方。然后你就可以挖掘到您的RTD服务器,看看有什么不顺心。

Perhaps you can test with a sample RTD server instead of your own, just to confirm that the error is there and not in the wrapper or elsewhere in the VSTO add-in. Then you can dig into your RTD server to see what goes wrong.

-Govert

Excel的DNA - 洒脱.NET为Excel

Excel-DNA - Free and easy .NET for Excel

这篇关于调用从Excel RTD服务器时异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆