本文介绍了ASP.NET中的CoInitializeSecurity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 您好, i尝试访问本地虚拟服务器对象。 我有一个带有按钮和文本框的aspx页面,这是代码: 公共类WebForm1:System.Web.UI.Page { protected System.Web.UI.WebControls .Button btnFillBox; protected System.Web.UI.WebControls.TextBox txtHost; protected System.Web.UI.WebControls.Label Label1; public enum RpcAuthnLevel { 默认= 0, 无= 1, 连接= 2, 电话= 3, Pkt = 4, PktIntegrity = 5, PktPrivacy = 6 } 公共枚举RpcImpLevel { 默认值= 0, Anonymous = 1, Identify = 2, Impersonate = 3, Delegate = 4 } 公共枚举EoAuthnCap { 无= 0x00, Mutua lAuth = 0x01, StaticCloaking = 0x20, DynamicCloaking = 0x40, AnyAuthority = 0x80, MakeFullSIC = 0x100, 默认= 0x800, SecureRefs = 0x02, AccessControl = 0x04, AppID = 0x08, 动态= 0x10, RequireFullSIC = 0x200, AutoImpersonate = 0x400, NoCustomMarshal = 0x2000, DisableAAA = 0x1000 } [DllImport(" ole32.dll")] public static extern int CoInitializeSecurity(IntPtr pVoid,int cAuthSvc,IntPtr asAuthSvc,IntPtr pReserved1,RpcAuthnLevel level, RpcImpLevel impers,IntPtr pAuthList,int dwCapabilities,IntPtr pReserved3); #region Web表单设计器生成的代码 覆盖protected void OnInit(EventArgs e) { // // CODEGEN:ASP.NET Web表格需要此调用 Designer。 // Initiali zeComponent(); base.OnInit(e); } ///< summary> /// Designer支持所需的方法 - 不要使用代码编辑器修改 ///此方法的内容。 ///< ; / summary> private void InitializeComponent() { this.btnFillBox.Click + = new System.EventHandler (this.btnFillBox_Click); this.Load + = new System.EventHandler(this.Page_Load); } #endregion [STAThread] private void btnFillBox_Click(object sender,System.EventArgs e) { this.txtHost.Text =""; CoInitializeSecurity(IntPtr.Zero,-1,IntPtr.Zero, IntPtr.Zero ,RpcAuthnLevel.PktIntegrity, RpcImpLevel.Identify,IntPtr.Zero,0x40,IntPtr.Zero); VMVirtualServerClass vs; vs = new VMVirtualServerClass(); this.txtHost.Text = vs.Version; } } } 我总是得到一个拒绝访问 on vs = new VMVirtualServerClass(); 我尝试过不同的CoInitializeSecurity组合,但没有 成功。 任何人都有通过 ASP.NET访问虚拟服务器(COM)的经验?或者VS有另一个可用的界面吗? 非常感谢 Clas - 隧道尽头的灯, 由于成本高而被关闭。Hello,i try to get access to a local virtual server object.I have a aspx page with a button and textbox, this is the code:public class WebForm1 : System.Web.UI.Page{protected System.Web.UI.WebControls.Button btnFillBox;protected System.Web.UI.WebControls.TextBox txtHost;protected System.Web.UI.WebControls.Label Label1;public enum RpcAuthnLevel{Default = 0,None = 1,Connect = 2,Call = 3,Pkt = 4,PktIntegrity = 5,PktPrivacy = 6}public enum RpcImpLevel{Default = 0,Anonymous = 1,Identify = 2,Impersonate = 3,Delegate = 4}public enum EoAuthnCap{None = 0x00,MutualAuth = 0x01,StaticCloaking= 0x20,DynamicCloaking= 0x40,AnyAuthority= 0x80,MakeFullSIC= 0x100,Default= 0x800,SecureRefs= 0x02,AccessControl= 0x04,AppID= 0x08,Dynamic= 0x10,RequireFullSIC= 0x200,AutoImpersonate= 0x400,NoCustomMarshal= 0x2000,DisableAAA= 0x1000}[DllImport("ole32.dll")]public static extern int CoInitializeSecurity( IntPtr pVoid, intcAuthSvc,IntPtr asAuthSvc, IntPtr pReserved1, RpcAuthnLevel level,RpcImpLevel impers,IntPtr pAuthList, int dwCapabilities, IntPtrpReserved3 );#region Web Form Designer generated codeoverride protected void OnInit(EventArgs e){//// CODEGEN: This call is required by the ASP.NET Web FormDesigner.//InitializeComponent();base.OnInit(e);}/// <summary>/// Required method for Designer support - do not modify/// the contents of this method with the code editor./// </summary>private void InitializeComponent(){this.btnFillBox.Click += new System.EventHandler(this.btnFillBox_Click);this.Load += new System.EventHandler(this.Page_Load);}#endregion[STAThread]private void btnFillBox_Click(object sender, System.EventArgs e){this.txtHost.Text = "";CoInitializeSecurity( IntPtr.Zero, -1, IntPtr.Zero,IntPtr.Zero,RpcAuthnLevel.PktIntegrity ,RpcImpLevel.Identify,IntPtr.Zero, 0x40, IntPtr.Zero );VMVirtualServerClass vs;vs = new VMVirtualServerClass();this.txtHost.Text = vs.Version;}}}I always get a "Access denied" on vs = new VMVirtualServerClass();I have tried different combinations for CoInitializeSecurity, but with nosuccess.Does anybody has experience of accessing a Virtual Server (COM) throughASP.NET ? Or is there another usable interface to VS ?Many thanksClas--The light at the end of the tunnel,was switch off due to high costs.推荐答案 这篇关于ASP.NET中的CoInitializeSecurity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-22 17:12