|
吾爱游客
发表于 2016-2-17 11:16
1、申 请 I D:516crazy
2、个人邮箱:86545816@qq.com
3、原创技术文章:自己写的代码
自己写activex的部分代码,IObjectSafety是公用的,自己的只是粘了一部分反射代码。
[Guid("DB5070BA-520E-42F6-8514-612901CD346D")]
public partial class AttachmentControl : UserControl, IObjectSafety
{
public AttachmentControl()
{
InitializeComponent();
}
#region IObjectSafety 成员
private const string _IID_IDispatch = "{00020400-0000-0000-C000-000000000046}";
private const string _IID_IDispatchEx = "{a6ef9860-c720-11d0-9337-00a0c90dcaa9}";
private const string _IID_IPersistStorage = "{0000010A-0000-0000-C000-000000000046}";
private const string _IID_IPersistStream = "{00000109-0000-0000-C000-000000000046}";
private const string _IID_IPersistPropertyBag = "{37D84F60-42CB-11CE-8135-00AA004BB851}";
private const int INTERFACESAFE_FOR_UNTRUSTED_CALLER = 0x00000001;
private const int INTERFACESAFE_FOR_UNTRUSTED_DATA = 0x00000002;
private const int S_OK = 0;
private const int E_FAIL = unchecked((int)0x80004005);
private const int E_NOINTERFACE = unchecked((int)0x80004002);
private bool _fSafeForScripting = true;
private bool _fSafeForInitializing = true;
public int GetInterfaceSafetyOptions(ref Guid riid, ref int pdwSupportedOptions, ref int pdwEnabledOptions)
{。。。}
public int SetInterfaceSafetyOptions(ref Guid riid, int dwOptionSetMask, int dwEnabledOptions)
{。。。}
#endregion
public Form CreateObjectDock(string classNamespace, string className)
{
object obj = null;
try
{
//Assembly assembly = Assembly.Load(classNamespace);
////从程序集中获取指定对象类型;
//Type type = assembly.GetType(classNamespace + "." + className);
//BandWay.DataManagement.PCS.ProjectServiceClient PCSClient = new BandWay.DataManagement.PCS.ProjectServiceClient(binding, new EndpointAddress("*****/PCDB/PC/"));
//BandWay.DataManagement.FLS.FileServiceClient FLSClient = new BandWay.DataManagement.FLS.FileServiceClient(binding, new EndpointAddress("*****/FLDB/File/"));
//BandWay.DataManagement.FLS.FileDownModel FLSModel = new BandWay.DataManagement.FLS.FileDownModel();
//obj = Activator.CreateInstance(type);
//System.Reflection.PropertyInfo propertyInfo = type.GetProperty("DBName");
//System.Reflection.PropertyInfo propertyInfo1 = type.GetProperty("FID");
//System.Reflection.PropertyInfo propertyInfo2 = type.GetProperty("WID");
//System.Reflection.PropertyInfo propertyInfo6 = type.GetProperty("PCSClient");
//propertyInfo.SetValue(obj, DBName, null);
//propertyInfo1.SetValue(obj, strFlowID, null);
//propertyInfo2.SetValue(obj, WorkID, null);
//propertyInfo6.SetValue(obj, PCSClient, null);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
return (Form)obj;
}
|
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|