Exception Message ="'Microsoft.Exchange.WebServices.Strings'的类型初始化程序引发异常。“ [英] Exception Message = "The type initializer for 'Microsoft.Exchange.WebServices.Strings' threw an exception."
问题描述
我正在尝试使用EWS托管api连接Exchange Server 2010,但我遇到以下例外情况:
I am trying to connect Exchange Server 2010 using EWS managed api, but I am getting following exceptions:
远程服务器返回错误:(401)未授权
The remote server returned an error: (401) Unauthorized
异常消息="'Microsoft.Exchange.WebServices.Strings'的类型初始化程序引发异常。"
Exception Message = "The type initializer for 'Microsoft.Exchange.WebServices.Strings' threw an exception."
下面是我正在使用的代码,它与msdn中的示例代码相同
below is the code which I am using, it's same sample code mention in msdn
ExchangeService
ExchangeService
service = new
ExchangeService (); < span style ="font-size:small">
service = new ExchangeService();
service.Credentials =
service.Credentials =
新
WebCredentials ( "用户名" ,
"密码" ,
" domain.contoso.com" );
new WebCredentials("UserName", "password", "domain.contoso.com");
//设置网址。
// Set the URL.
service.AutodiscoverUrl(
service.AutodiscoverUrl(
" User1@contoso.com" );
"User1@contoso.com");
控制台 。WriteLine( " hello!" );
Console.WriteLine("hello!");
控制台 。ReadLine();
Console.ReadLine();
推荐答案
我遇到了同样的问题。也许我们的机器上没有安装必要的组件?我的服务器上有这段代码很长时间了以前(超过一年前)。我不是要调试问题,我在我的
dev机器上遇到了这个错误......
I ran into the same problem. maybe we don't have a necessary component installed on our machine? I had this code working on my server a long time ago (over a year ago). i'm not trying to debug the problem and i ran into this error on my dev machine...
我肯定会感谢这里的任何暗示或指示。
i sure would be grateful for any hint or direction here.
谢谢,
账单
Bill
这篇关于Exception Message ="'Microsoft.Exchange.WebServices.Strings'的类型初始化程序引发异常。“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!