Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么在我使用线程池获得.Net应用程序的呈现层后,Excel中的DDE调用会挂起?_.net_Wpf_Excel_Dde - Fatal编程技术网

为什么在我使用线程池获得.Net应用程序的呈现层后,Excel中的DDE调用会挂起?

为什么在我使用线程池获得.Net应用程序的呈现层后,Excel中的DDE调用会挂起?,.net,wpf,excel,dde,.net,Wpf,Excel,Dde,我发现了一个非常奇怪的问题,如果我使用ThreadPool获取.Net应用程序的渲染层,它将挂起来自Excel的一个非常简单的DDE调用。在从Excel调用DDE的同时运行复杂的WPF应用程序时,发现了该问题。我已经设法在下面的几行代码中重现了这个问题 C#.Net应用程序 Excel DDE宏 Sub Using_DDE1() ' Dimension the variables. Dim Chan As Integer Dim RequestItems As Variant

我发现了一个非常奇怪的问题,如果我使用ThreadPool获取.Net应用程序的渲染层,它将挂起来自Excel的一个非常简单的DDE调用。在从Excel调用DDE的同时运行复杂的WPF应用程序时,发现了该问题。我已经设法在下面的几行代码中重现了这个问题

C#.Net应用程序

Excel DDE宏

Sub Using_DDE1()

  ' Dimension the variables.
  Dim Chan As Integer
  Dim RequestItems As Variant

  ' Start a channel to Word using the System topic.
  Chan = DDEInitiate("WinWord", "System")

  ' Requesting information from Word using the Formats item
  ' this will return a one dimensional array.
  RequestItems = DDERequest(Chan, "Formats")

  ' Uses a FOR loop to cycle through the array and display in a message box.
  For i = LBound(RequestItems) To 3

      MsgBox RequestItems(i)

  Next i

  ' Terminate the DDE channel.
  DDETerminate Chan

  End Sub 
单独运行宏时,运行宏将显示3个消息框。如果我在c#应用程序运行时尝试运行宏,它将挂起对DDEISTATE的调用。c#app一关闭,excel就恢复了活力。从主线程获取渲染层不会导致问题。我还注意到,如果调试器暂停,即使尚未调用获取渲染层,宏也会挂起

使用Windows Xp和Excel 2003、.Net3.5和.Net4以及Windows 7和Excel 2010、.Net3.5和.Net4复制的问题

知道为什么会这样吗?这是PresentationCore.dll的错误吗

谢谢你的帮助

[更新]

更改机器的渲染层似乎可以释放这个“锁”(之后我不得不移动一些窗口)。我正在通过启动NetMeeting更改渲染层,但可以通过强制图形卡在“显示属性”中使用软件渲染来完成此操作。

这可能有助于:

如果在基于Windows 2000或基于Windows XP的计算机上运行的其他程序未正确处理Windows消息循环,则使用DDE的程序将停止响应

你可以找到它

这仅在32位Windows中发生,并且只有DDE客户端受到影响。要建立连接,应用程序将向所有顶级窗口广播消息。如果窗口不在同一个线程上,则消息实际上已发布到收件人队列,并且调用者被阻止。如果收件人没有消息队列,则调用线程将被永久阻止。微软已经承认这是一个bug


更多详细信息请参阅知识库文章BUG:DdeConnect Never Returns

嗨,雅各布,这句话的来源是什么?
Sub Using_DDE1()

  ' Dimension the variables.
  Dim Chan As Integer
  Dim RequestItems As Variant

  ' Start a channel to Word using the System topic.
  Chan = DDEInitiate("WinWord", "System")

  ' Requesting information from Word using the Formats item
  ' this will return a one dimensional array.
  RequestItems = DDERequest(Chan, "Formats")

  ' Uses a FOR loop to cycle through the array and display in a message box.
  For i = LBound(RequestItems) To 3

      MsgBox RequestItems(i)

  Next i

  ' Terminate the DDE channel.
  DDETerminate Chan

  End Sub