简体   繁体   English

用于Visual Studio的Visio加载项专家

[英]Visio Add-in Experts for Visual Studio

I was wondering if anybody had any experience with dealing with managed code add-ins specifically for Visio in a .NET project. 我想知道是否有人在.NET项目中有专门处理Visio的托管代码加载项的经验。 I am messing around with one and am trying to remove hyperlinks from a Shape object. 我搞砸了,并试图从Shape对象中删除超链接。 Deleting them works fine and if the user saves then all works well. 删除它们可以正常工作,如果用户保存,则一切正常。 The problem arises when the user does not save and is prompted by Visio, before close, that there are unsaved changes and wants to know what the user wants to do. 当用户不保存并且在关闭前Visio提示您存在未保存的更改并想知道用户想要做什么时,就会出现问题。 If the user selects "Don't save" and just tries to exit, the Visio application crashes with an unhandled Win32 exception that I have traced back to an Exception code: 0xc0000005 in the Windows Event Viewer. 如果用户选择“不保存”并试图退出,则Visio应用程序将崩溃,并出现一个未处理的Win32异常,该异常已追溯至Windows事件查看器中的异常代码:0xc0000005。 This turns out to be an "Access Violation Error". 原来是“访问冲突错误”。 I have found the issue to be a line of code that calls the Delete method on the Hyperlinks collection of a shape (Example below). 我发现问题是一行代码调用了形状的超链接集合上的Delete方法(下面的示例)。 Anybody know what is going on here? 有人知道这是怎么回事吗? Is this a MS bug that I just can't find on the Google? 这是我在Google上找不到的MS错误吗? Hope I have enough information for you guys here. 希望我在这里为您提供足够的信息。 Did not think I needed to post a bunch of code since I have found only this line of code produces the exception when Visio tries to exit after a do not save. 没想到我需要发布一堆代码,因为当Visio在不保存后尝试退出时,我发现只有这一行代码会产生异常。 I have found this to produce the exact error with versions 12 and 14 of the Microsoft.Office.Interop.Visio.dll. 我发现这会与Microsoft.Office.Interop.Visio.dll版本12和14产生确切的错误。

 internal static Nullable<Boolean> DeleteFirstHyperlink(Shape shape) { if(true){ //a condition to pass shape.Hyperlinks.get_ItemU(0).Delete(); return true; } else{ return false; } } 

I think you might be deleting hyperlinks from a "before shape deleted" event handler? 我认为您可能正在从“形状被删除之前”事件处理程序中删除超链接? I this case, you should not do that. 在这种情况下,您不应该这样做。 Instead, you can remember what to delete and delete it afterwards in "no events pending" / "shape deleted" event handler.. Or it may be some similar case. 取而代之的是,您可以记住在“没有待处理的事件” /“形状已删除”的事件处理程序中要删除和删除的内容。或者可能是类似的情况。

Check here: https://msdn.microsoft.com/en-us/library/office/ff767512.aspx 在这里检查: https : //msdn.microsoft.com/en-us/library/office/ff767512.aspx

After Visio has fired the MustFlushScopeBeginning event, client programs should not call Visio methods that have side effects until the MustFlushScopeEnded event is received. 在Visio触发MustFlushScopeBeginning事件之后,在收到MustFlushScopeEnded事件之前,客户端程序不应调用具有副作用的Visio方法。 A client can perform arbitrary queries of Visio objects when Visio is between the MustFlushScopeBeginning event and MustFlushScopeEnded event, but operations that cause side effects may fail. 当Visio在MustFlushScopeBeginning事件和MustFlushScopeEnded事件之间时,客户端可以对Visio对象执行任意查询,但是导致副作用的操作可能会失败。

If this is not the case, then probably one would need a complete example illustrating the problem (full source code illustrating the problem) to figure out what is going on. 如果不是这种情况,那么可能需要一个完整的示例来说明问题(完整的源代码说明问题)以找出问题所在。

I mean, normally you can delete hyperlinks without any issues. 我的意思是,通常您可以删除超链接而不会出现任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM