Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/267.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.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
C# VSTO Office加载项在打开MessageBox时出现异常_C#_.net_Vsto - Fatal编程技术网

C# VSTO Office加载项在打开MessageBox时出现异常

C# VSTO Office加载项在打开MessageBox时出现异常,c#,.net,vsto,C#,.net,Vsto,我在.Net C#中实现了一个MS Office Word加载项。 在特定情况下,当我尝试打开消息框时 MessageBox.Show() 我有个例外 System.Runtime.Serialization.SerializationException 这显然与MessageBox无关 流程是这样的 1- Perform call to MessageBox.Show() -> All goes well 2- Perform some WCF calls -> All

我在.Net C#中实现了一个MS Office Word加载项。 在特定情况下,当我尝试打开消息框时

MessageBox.Show()
我有个例外

System.Runtime.Serialization.SerializationException 
这显然与MessageBox无关

流程是这样的

 1- Perform call to MessageBox.Show() -> All goes well
 2- Perform some WCF calls -> All goes well
 3- Perform a new call to MessageBox.Show() -> I get the exception
例外是

System.Runtime.Serialization.SerializationException: Type is not resolved for member XXX
其中XXX是

System.Security.Principal.IPrincipal
有没有人知道我可能做错了什么。 如果我跳过第2步,那么第3步也可以。
如果我跳过步骤1(第一个消息框显示),只执行步骤2和步骤3,那么它也可以正常工作。

我过去也遇到过同样的问题

您正在使用自定义标识吗?如果是这样,请确保您的标识是[Serializable],并实现ISerializable接口。这会解决你的问题

(这是关于服务器应用程序的,但如果您使用Office并致电WCF,则同样适用)


但我无法理解为什么需要这样做。

你能分享你的第三个messagebox.show代码。返回messagebox.show(消息、标题、按钮、图标、默认按钮);其中message和title是字符串,buttons=MessageBoxButtons.OK,icon=MessageBoxIcon.Information,defaultButton=MessageBoxDefaultButton.button1您是否能够将您的代码简化为可以发布在此处、重新编写并可以放入项目中进行测试的代码?这真是太多太少的信息…谢谢。这很有帮助。这是多么奇怪的错误和行为啊。