473,320 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Using COM in asp.net project

HTM
Hi All,

I have a third party COM object done in C++. I want to use this COM object in my asp.net project. I'm able to add reference and initialize the object but when I'm getting a run-time error below:


Server Error in '/aspnet/fsc' Application.
--------------------------------------------------------------------------------

ERROR: Unable to Create an Instance of the Server
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: ERROR: Unable to Create an Instance of the Server

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

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 appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[UnauthorizedAccessException: ERROR: Unable to Create an Instance of the Server]
STEALTHRATERAPILib.AutoClass.GetMaritalStatus(Int3 2 nAgentID) +0
fsc.auto_profile.Page_Load(Object sender, EventArgs e) in f:\aspnet\fsc\auto_profile.aspx.cs:25
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731



--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
The ASP.Net account has been granted the access to the DLL but I'm still getting this error. Is there something else I'm missing when referencing the DLL? Should there be an Interop DLL to be added to the project in order for this to work?

Thanks very much
Henry
Jul 21 '05 #1
2 2313
Hi

All you should need to do is to add the reference - VS.NET creates the interop dll for you, so you're not missing anything here. Below are some pointers that may help you...
The security context (user) that your code is running under is determined by two factors:
1. is anonymous access is enabled for the site/virtual-folder in IIS?
2. is impersonation enabled in web.config?
One way to find out which user needs access to the COM component is to add something like this just before your call:
....
IIdentity i = System.Threading.Thread.CurrentPrincipal.Identity;
System.Diagnostics.Debug.WriteLine(i.Name);
// call COM component
....

Does your COM component use any other files/folders?

If your web application runs with anything other than full trust, you may also run into code access security problems (because the COM component is unmanaged code which requires full trust) - but I think you will get a different exception if that was the case here.

Richard.
"HTM" <hm**@superioraccess.net> wrote in message news:eC*************@TK2MSFTNGP09.phx.gbl...
Hi All,

I have a third party COM object done in C++. I want to use this COM object in my asp.net project. I'm able to add reference and initialize the object but when I'm getting a run-time error below:
Server Error in '/aspnet/fsc' Application.
------------------------------------------------------------------------------

ERROR: Unable to Create an Instance of the Server
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: ERROR: Unable to Create an Instance of the Server

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

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 appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[UnauthorizedAccessException: ERROR: Unable to Create an Instance of the Server]
STEALTHRATERAPILib.AutoClass.GetMaritalStatus(Int3 2 nAgentID) +0
fsc.auto_profile.Page_Load(Object sender, EventArgs e) in f:\aspnet\fsc\auto_profile.aspx.cs:25
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731



------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
The ASP.Net account has been granted the access to the DLL but I'm still getting this error. Is there something else I'm missing when referencing the DLL? Should there be an Interop DLL to be added to the project in order for this to work?

Thanks very much
Henry

Jul 21 '05 #2
Hi

All you should need to do is to add the reference - VS.NET creates the interop dll for you, so you're not missing anything here. Below are some pointers that may help you...
The security context (user) that your code is running under is determined by two factors:
1. is anonymous access is enabled for the site/virtual-folder in IIS?
2. is impersonation enabled in web.config?
One way to find out which user needs access to the COM component is to add something like this just before your call:
....
IIdentity i = System.Threading.Thread.CurrentPrincipal.Identity;
System.Diagnostics.Debug.WriteLine(i.Name);
// call COM component
....

Does your COM component use any other files/folders?

If your web application runs with anything other than full trust, you may also run into code access security problems (because the COM component is unmanaged code which requires full trust) - but I think you will get a different exception if that was the case here.

Richard.
"HTM" <hm**@superioraccess.net> wrote in message news:eC*************@TK2MSFTNGP09.phx.gbl...
Hi All,

I have a third party COM object done in C++. I want to use this COM object in my asp.net project. I'm able to add reference and initialize the object but when I'm getting a run-time error below:
Server Error in '/aspnet/fsc' Application.
------------------------------------------------------------------------------

ERROR: Unable to Create an Instance of the Server
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: ERROR: Unable to Create an Instance of the Server

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

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 appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[UnauthorizedAccessException: ERROR: Unable to Create an Instance of the Server]
STEALTHRATERAPILib.AutoClass.GetMaritalStatus(Int3 2 nAgentID) +0
fsc.auto_profile.Page_Load(Object sender, EventArgs e) in f:\aspnet\fsc\auto_profile.aspx.cs:25
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731



------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
The ASP.Net account has been granted the access to the DLL but I'm still getting this error. Is there something else I'm missing when referencing the DLL? Should there be an Interop DLL to be added to the project in order for this to work?

Thanks very much
Henry

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jimmy Tran | last post by:
Hi Folks, I have a web database written in asp and using access97. I have many projects, but each project is being held responsible by a person. All people and projects come from the database....
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
5
by: Derek Martin | last post by:
I am creating a windows service and have added a reference to a DLL project that I have created. That DLL file is correctly referenced in both a windows app and a web app, all in the same...
2
by: Bill Nguyen | last post by:
I would like to add a new VB.NET project using the same folder being used by another project so that I can share several forms already creaded by the other project. However, .NET created a new...
1
by: Diffident | last post by:
Hello All, I have a question as to why my users are noticing error when I am building the project on the production system. Here is the problem's background. In order to build the project on...
8
by: Bruce | last post by:
I am using VB in Vs2005. Am I missing something or does VB not have the concept of "builds" (release/debug) like in VC? I wrote an assembly and I would like to have a debug version of the DLL...
12
by: BDowling | last post by:
Hi all, I have an existing Visual C++ project that builds a DLL (not COM or ATL or anything). I wish to use this DLL in a Visual Studio 2005 C# project without having to define each function and...
6
by: =?Utf-8?B?WW9naSBXYXRjaGVy?= | last post by:
Hello, I am using Visual Studio-2003. I created a project to build my library. Since I am using third party libraries as well, I have specified those additional library dependencies in project...
6
by: Daniel Kraft | last post by:
Hi all, in my C++ projects, I usually make "heavy use" of namespaces to "encapsulate" my code. When I have for instance something like this: namespace project { namespace part1 { ... }...
3
by: Jeff | last post by:
I have a solution with two projects. Project A is the startup project, while Project B serves as the project with the data logic. At run time, the first thing I need to do is write to Project...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.