COM+ Application Libary/Server Activation

Posted on 2003-03-14
Medium Priority
Last Modified: 2013-11-25
I have created a serviced component using VB.NET. I have set the Actication type to Library and create a test application using normal exe. It works..

But when I call it from ASP.NET it fails with the following error :=

Server Error in '/WebApplication1' Application.

Access is denied.
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.UnauthorizedAccessException: Access is denied.

The ASP.NET process is not authorized to access the requested resource. For security reasons the default ASP.NET process identity is '{machinename}\ASPNET', which has limited privileges. Consider granting access rights to the resource to the ASP.NET process identity.

To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the "{machinename}\ASPNET" user. Highlight the ASP.NET account, and check the Write box in the Allow column.

Source Error:

Line 25:         Dim a As ClassLibrary1.Poolable
Line 26:
Line 27:         a = New ClassLibrary1.Poolable()
Line 28:     End Sub
Line 29: End Class

Source File: c:\inetpub\wwwroot\WebApplication1\WebForm1.aspx.vb    Line: 27

Stack Trace:

[UnauthorizedAccessException: Access is denied.]
   System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode, IntPtr errorInfo) +0
   System.EnterpriseServices.Thunk.Proxy.CoCreateObject(Type serverType, Boolean bQuerySCInfo, Boolean& bIsAnotherProcess, String& uri) +587
   System.EnterpriseServices.ServicedComponentProxyAttribute.CreateInstance(Type serverType) +181
   System.Runtime.Remoting.Activation.ActivationServices.CreateInstanceWithLinkDemand(ProxyAttribute pa, Type serverType) +4
   System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(Type serverType, Object[] props) +122
   WebApplication1.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\WebApplication1\WebForm1.aspx.vb:27
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain() +1263

I tried changing the Activation to Server and the page works. Why is this happening ? How can I make it work again ? thank you very much..

Need your help..
Question by:fkmfkm
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8137975
Basically the answer to your question lies in the statmenent.

The ASP.NET process is not authorized to access the requested resource. For security reasons the default ASP.NET process identity is '{machinename}\ASPNET', which has limited privileges. Consider granting access rights to the resource to the ASP.NET process identity.

When you run the component from a windows application it is running under the user id of the person log on the machine. That person (you) has the rights to run such an application.  When you run an asp page the process must run under a user id, but since any user migth be accesing the page the user asigned to the page has limited authority.  What you have to do is to assign the proper authority to the dll.  Unfortunately, I have not yet reach that chapter on my book.
LVL 10

Accepted Solution

GoodJun earned 500 total points
ID: 8138569
You can do it through impersonation.
From your web.config file
<identity impersonate=true>
this will use the client identity to run the app. IIS has to set window authentication to use this.

or you can impersonate a user to run this app:
<identity impersonate="true" userName="contoso\Jane" password="pass" />
This enables the entire application to run as contoso\Jane, regardless of the identity of the request, so long as the password is correct. This type of impersonation can be delegated to another computer.


Expert Comment

ID: 8142121
u can change the machine.config file
and changin 'machine' to 'SYSTEM'
and it will work
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.


Author Comment

ID: 8152072
How should i give the points to GoodJun and yosit ?
LVL 10

Expert Comment

ID: 8155395
Did you solved your problem? If not, we can guide you through to make it work.


Author Comment

ID: 8189794
How if I am doing normal ASP 3.0 pages ?
LVL 10

Expert Comment

ID: 8197964
asp 3.0 also support impersonation.
Thanks for the grade.

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question