日期:2014-05-17  浏览次数:21173 次

程序一旦运行到propertySet.GetProperty("password")就死
本帖最后由 shujujiegougou 于 2013-10-07 18:17:45 编辑
申请propertySet并向其中存入server、instance等信息


IPropertySet propertySet = new PropertySetClass();

propertySet.SetProperty("server", this.textBox1.Text);
propertySet.SetProperty("instance", this.textBox2.Text);
propertySet.SetProperty("database", this.textBox3.Text);
propertySet.SetProperty("user", this.textBox4.Text);
propertySet.SetProperty("password", this.textBox5.Text);


然后在后面的代码中,我打算取出propertySet中的信息

sdeCon.ServerName = propertySet.GetProperty("server").ToString();
sdeCon.Instance = propertySet.GetProperty("instance").ToString();
sdeCon.UserName = propertySet.GetProperty("user").ToString();
sdeCon.Password = propertySet.GetProperty("password").ToString();
sdeCon.Database = propertySet.GetProperty("database").ToString();


server、instance、user这些信息都能正常取出,但是取password时总是报错,错误信息:
propertySet.GetProperty("password")”引发了“System.Runtime.InteropServices.COMException”类型的异常

截图如下:


这是什么原因呢?怎么解决?

------解决方案--------------------
导致这个问题的原因很多。

有可能是安全问题,参考:
http://blog.csdn.net/mr_wanter/article/details/8847898

但是也可能是别的问题。总之和com组件本身有关。