all groups > dotnet component services > october 2004 >
You're in the

dotnet component services

group:

Access Denied to Serviced Component When calling from Windows Client



Access Denied to Serviced Component When calling from Windows Client lhak
10/9/2004 1:31:17 PM
dotnet component services: Hi,
Hope someone can help me with this problem. I've written a Serviced
Component (VB.Net), signed it with a strong name (using SN.exe) and
registered it with the COM+ Catalog and added it to the GAC successfully. I
could see the component thru the Administrative Tools - Component Services
etc.

I wrote a windows app to instantiate the component but when the client app
tries to instantiate the component, an exception message of "Access Denied"
is displayed.

Can anyone tell how to fix this?. Below are my codes and exception
messages:

Thanks in advance.
LH


****Start - My Client Application codes****

Private nsc As NorthwindSC
Private Sub NorthwindSCGreedyClient_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
nsc = New NorthwindSC <==== Error occurs here.
End Sub
Private Sub btnUpdate_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
Try
Dim intRows As Integer = nsc.UpdateData(CType(dgResults.DataSource,
DataSet))
MessageBox.Show(String.Format("{0} row(s) updated successfully", intRows), "
row(s) updated", MessageBoxButtons.OK, MessageBoxIcon.Information)
dgResults.DataSource = nsc.ExecuteQuery(txtQuery.Text)
dgResults.DataMember = "Results"
Catch ex As Exception
MessageBox.Show(ex.Message, "Update Failed", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Private Sub btnExecute_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnExecute.Click
Try
dgResults.DataSource = nsc.ExecuteQuery(txtQuery.Text)
dgResults.DataMember = "Results"
Catch ex As Exception
MessageBox.Show(ex.Message, "Invalid Query", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
*** End - My Client Application codes***
***Start - Exception Messages***

System.UnauthorizedAccessException: Access is denied.
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32
errorCode, IntPtr errorInfo)
at System.EnterpriseServices.Thunk.Proxy.CoCreateObject(Type serverType,
Boolean bQuerySCInfo, Boolean& bIsAnotherProcess, String& uri)
at
System.EnterpriseServices.ServicedComponentProxyAttribute.CreateInstance(Typ
e serverType)
at
System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(Typ
e serverType, Object[] props, Boolean bNewObj)
at
StepByStep7_9.NorthwindSCGreedyClient.NorthwindSCGreedyClient_Load(Object
sender, EventArgs e) in
D:\CSU\ITI563\Ch07\310C07\StepByStep7_9\NorthwindSCGreedyClient.vb:line 122
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
StepByStep7_9
Assembly Version: 1.0.1743.22343
Win32 Version: 1.0.1743.22343
CodeBase:
file:///D:/CSU/ITI563/Ch07/310C07/StepByStep7_9/bin/StepByStep7_9.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c56193
4e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.d
ll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/
system.drawing.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/syst
em.xml.dll
----------------------------------------
StepByStep7_8
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase:
file:///c:/windows/assembly/gac/stepbystep7_8/1.0.0.0__cc6409be549f8706/step
bystep7_8.dll
----------------------------------------
System.EnterpriseServices
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.enterpriseservices/1.0.5000.0__b03f5f
7f11d50a3a/system.enterpriseservices.dll
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
****End - Exception Messages****

Re: Access Denied to Serviced Component When calling from Windows Client Frank Mamone
10/10/2004 10:24:02 AM
I ran into this too. I went into the COM+ Catalog in the properties of the
component. In the Security Tab you will find a checkbox to "Enforce access
checks..." I unchecked it and it worked.

It is kind of strange as in other SC's they work with the setting enforced.

- Frank


[quoted text, click to view]

Re: Access Denied to Serviced Component When calling from Windows Client Mike Dice [MSFT]
10/10/2004 9:00:36 PM
Access checks are enforced by default on newer platforms (eg. Win2k3 and XP
SP2) and not on older ones (win2k) so you would see different behavior
depending on the platform you were running on.

Pay attention to security. If you really don't want to enforce access checks
then turn them off when you create the applicaiton. You can do this in
managed code by adding an assembly level ApplicationAccessContraol
attribute.

Example in C#:
[assembly: ApplicationAccessControl(false)]

This has the same effect as unchecking 'Enforce Security Checks' in COM+
settings as Frank mentioned.

I don't recommend ignoring security like this though. You should think about
who is allowed to access your components and enforce access checks so only
intended clients can access the app.

MikeDice [MSFT]

[quoted text, click to view]
AddThis Social Bookmark Button