COM+ Secure Method

G

Guest

Continuation of 21410546

Original Post

To give some background....I'm using COM+ security in my C# classes by applying the ComponentAccessControl, and SecureMethod attributes at class level. I also use the SecurityRole attributes for any roles that I want to have access to the whole class. I then also use the SecurityRole attribute at method level to grant access to specific methods for specific roles

My issue is that I have a separate assembly sitting in the GAC that contains a number of structs. These structs are populated from my within my application and are passed up to my middle tier and are used to update my database. Now when my UI, populates a struct, and attempts to call into my C# class (hosted in COM+), and I have set the [SecureMethod] attribute (at class level), my application fails with the following exception mesage; "An internal error occurred in a remote procedure call (RPC)". But as soon as I comment out the [SecureMethod] attribute, rebuild my class & add it back into COM+, I no longer get the above error

This error only appears to happen when I call into methods that use structs. I can call into other components, and the method fires successfully...

Further details

Stack Trace

An internal error occurred in a remote procedure call (RPC).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more

information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: An internal error occurred in a remote procedure call (RPC)

Source Error:

Line 40: CustomerData.IMyTestClass myComponent = new CustomerData.MyTestClass()
Line 41:
Line 42: myComponent.AddSalesKPI(myStruct)
Line 43:
Line 44:


Source File: C:\Inetpub\wwwroot\WebAppTestCOMStruct\WebForm1.aspx.cs Line: 42

Stack Trace:

[COMException (0x800706e6): An internal error occurred in a remote procedure call (RPC).
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +26
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +69
Spicers.Systems.Customer.TestCOM.IMyTestClass.AddSalesKPI(SalesKPIStruct salesKPIData) +
WebAppTestCOMStruct.WebForm1.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\WebAppTestCOMStruct\WebForm1.aspx.cs:4
System.Web.UI.Control.OnLoad(EventArgs e) +6
System.Web.UI.Control.LoadRecursive() +2
System.Web.UI.Page.ProcessRequestMain() +71



-------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.0.3705.288; ASP.NET Version:1.0.3705.28


Web server & components are both running on the same machine (Win2000

My COM component contains the following code

using System
using System.EnterpriseServices
using DataObj = Spicers.Systems.Customer.DataObjects
using CustData = Spicers.Systems.Customer.Data
using System.Runtime.InteropServices
using System.Data

namespace Spicers.Systems.Customer.TestCO

[Guid("BEC50304-3189-4266-A057-E7CF0142FCD9")
public interface IMyTestClas

void AddSalesKPI(DataObj.KPI.SalesKPIStruct salesKPIData)
DataSet GetSalesKPIByRepAndYear(string repCode, short year)


[Guid("93509CF9-DE0A-4a70-8B21-9402DB2AAF78")
[ComponentAccessControl
[SecurityRole("Admin")
[SecurityRole("Sales")
[SecureMethod
[Serializable
public class MyTestClass : ServicedComponent, IMyTestClas

public MyTestClass(

// constructo


public void AddSalesKPI(DataObj.KPI.SalesKPIStruct salesKPIData

CustData.KPI kpi = new CustData.KPI()

kpi.AddSalesKPI(salesKPIData)


[SecurityRole("Enquiry")
public DataSet GetSalesKPIByRepAndYear(string repCode, short year

// create instance of data tie
CustData.KPI kpi = new CustData.KPI()
// pass back object containin dat
return kpi.GetSalesKPIByRepAndYear(repCode,year)




I created a web app to call this COM component. (The web form itself doesn't have any functionality apart from creating an instance of my

component, then populates my struct (which sits in the GAC), and then passes the struct as a parameter to a method on my component. Now

as soon as I comment out the [SecureMethod] attribute, the call to the component is successful. However, as soon as I add the attribute

back, then the method call fails.

My struct that sits in the GAC is as follows:

[Serializable]
public struct SalesKPIStruct
{
public string RepCode;
public string Year;
public string SalesGrowth;
public string GrossMargin;
public string CombinedSalesMargin;
public string CatalogueSales;
public string DirectMailSales;
public string Promotions;
}

Code sample from my web form:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.EnterpriseServices;
using CustomerStruct = Spicers.Systems.Customer.DataObjects;
using CustomerData = Spicers.Systems.Customer.TestCOM;



namespace WebAppTestCOMStruct
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
CustomerStruct.KPI.SalesKPIStruct myStruct = new CustomerStruct.KPI.SalesKPIStruct();

myStruct.CatalogueSales = "99";
myStruct.CombinedSalesMargin = "99";
myStruct.DirectMailSales = "99";
myStruct.GrossMargin = "99";
myStruct.Promotions = "99";
myStruct.RepCode = "TT";
myStruct.SalesGrowth = "99";
myStruct.Year = "2004";

CustomerData.IMyTestClass myComponent = new CustomerData.MyTestClass();

myComponent.AddSalesKPI(myStruct);
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
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.Load += new System.EventHandler(this.Page_Load);

}
#endregion

}
}

Best wishes
David
 
T

Tian Min Huang

Hi David,

Thanks for your post. I noticed that Scott used to work with you on this
incident. I will involve him to update you as soon as possible.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top