N
Nick Palmer
I thought I'd pass this one along to the group as I know that this was an
issue that someone else here had run into. After going round and round with
this problem internally, we finally contacted Microsoft and worked with them
to resolve the issue.
The problem basically involved ASP.NET code running on a Windows Server
2003/IIS 6 that fails to execute an OWC11.Spreadsheet.Copy method call. The
same call succeeds on Window 200/IIS 5, or when the Windows 2003 Server
machine is configured to run in IIS 5.0 Compatibility Mode.
It turns out that internally, the OWC11.Spreadsheet.Copy makes a call to
OpenClipboard, even when specifying a destination range. When a
destination range is specified, no data is passed to or read from the
clipboard, but the call to OpenClipboard is still made. The problem is on a
Windows 2003 server running IIS 6 in native mode, the account that is
running the code does not have access to the clipboard. This caused an
Access Denied error and the Copy doesn't complete. Originally it was
thought that it might be possible to get around this by simply having the
Application Pool that ran the ASP.NET app run as a different user, one with
more elevated privileges, but that still didn't resolve the problem.
So, the workaround/solution to the problem is as follows. We created a VB6
ActiveX dll that we registered into COM+ as a server library. This VB6
ActiveX Dll creates an instance of an OWC11.Spreadsheet and returns a
reference to the calling ASP.NET code. Because the VB6 Dll is running in its
own process space under the network service account, the OWC11.Spreadsheet
will run in this process space, and have access to the clipboard. This
allows the call to OpenClipboard to succeed. I have attached some sample
code below for those interested.
'
****************************************************************************
**********************
ASP.NET (VB.NET) code :
Dim oWrapper As Object
oWrapper = CreateObject("OWCSS_Wrapper.SSWrapper")
Dim o As OWC11.Spreadsheet
o = oWrapper.SS
o.Cells(1, 1).Value = "Hello There"
o.Range("A1").Copy(o.Range("B1"))
System.Runtime.InteropServices.Marshal.ReleaseComObject(oWrapper)
Response.Write("Complete")
'
****************************************************************************
**********************
VB6 Project
Project ID : OWCSS_Wrapper
Class module Name : SSWrapper
References : Microsoft Office Web Components 11.0
Code :
Option Explicit
Private m_objSS As OWC11.Spreadsheet
Private Sub Class_Initialize()
Set m_objSS = CreateObject("OWC11.Spreadsheet")
End Sub
Private Sub Class_Terminate()
Set m_objSS = Nothing
End Sub
Public Property Get SS() As OWC11.Spreadsheet
Set SS = m_objSS
End Property
'
****************************************************************************
**********************
When create the COM+ object, you need to set the setup the security
correctly. Right click on your application and choose Properties. In the
Properties dialog, click the Security tab and clear the checkbox for
"Enforce access checks for this application"
If you are not using Role based security in your ASP.net code then there is
very little impact in unchecking this.
If you want to leave it checked, then this is the procedure to use:
Navigate to the COM+ Application (same as above) Note there Are 3 folders
and the bottom one is called Roles Right click Roles and pick New Role, and
enter a Name (for example, ASPNet Users) and click OK Expand the New Role,
and right click the Users subfolder and click New->User Type Network Service
in the box and click Check Names (to make sure it matches) and then click OK
Expand the Components folder and right click the OWCSS_Wrapper.SSWrapper and
click Properties Go to the Security Tab, and check the box by ASPNet User in
the list, and click OK.
One last configuration issue. You will need to make sure that the account
that you have setup the COM+ application to run as, has read access to the
directory where you have the VB6 OWC wrapper file. If the user account
doesn't have access to the file, COM+ will be unable to create the object.
Hope this helps,
Nick
issue that someone else here had run into. After going round and round with
this problem internally, we finally contacted Microsoft and worked with them
to resolve the issue.
The problem basically involved ASP.NET code running on a Windows Server
2003/IIS 6 that fails to execute an OWC11.Spreadsheet.Copy method call. The
same call succeeds on Window 200/IIS 5, or when the Windows 2003 Server
machine is configured to run in IIS 5.0 Compatibility Mode.
It turns out that internally, the OWC11.Spreadsheet.Copy makes a call to
OpenClipboard, even when specifying a destination range. When a
destination range is specified, no data is passed to or read from the
clipboard, but the call to OpenClipboard is still made. The problem is on a
Windows 2003 server running IIS 6 in native mode, the account that is
running the code does not have access to the clipboard. This caused an
Access Denied error and the Copy doesn't complete. Originally it was
thought that it might be possible to get around this by simply having the
Application Pool that ran the ASP.NET app run as a different user, one with
more elevated privileges, but that still didn't resolve the problem.
So, the workaround/solution to the problem is as follows. We created a VB6
ActiveX dll that we registered into COM+ as a server library. This VB6
ActiveX Dll creates an instance of an OWC11.Spreadsheet and returns a
reference to the calling ASP.NET code. Because the VB6 Dll is running in its
own process space under the network service account, the OWC11.Spreadsheet
will run in this process space, and have access to the clipboard. This
allows the call to OpenClipboard to succeed. I have attached some sample
code below for those interested.
'
****************************************************************************
**********************
ASP.NET (VB.NET) code :
Dim oWrapper As Object
oWrapper = CreateObject("OWCSS_Wrapper.SSWrapper")
Dim o As OWC11.Spreadsheet
o = oWrapper.SS
o.Cells(1, 1).Value = "Hello There"
o.Range("A1").Copy(o.Range("B1"))
System.Runtime.InteropServices.Marshal.ReleaseComObject(oWrapper)
Response.Write("Complete")
'
****************************************************************************
**********************
VB6 Project
Project ID : OWCSS_Wrapper
Class module Name : SSWrapper
References : Microsoft Office Web Components 11.0
Code :
Option Explicit
Private m_objSS As OWC11.Spreadsheet
Private Sub Class_Initialize()
Set m_objSS = CreateObject("OWC11.Spreadsheet")
End Sub
Private Sub Class_Terminate()
Set m_objSS = Nothing
End Sub
Public Property Get SS() As OWC11.Spreadsheet
Set SS = m_objSS
End Property
'
****************************************************************************
**********************
When create the COM+ object, you need to set the setup the security
correctly. Right click on your application and choose Properties. In the
Properties dialog, click the Security tab and clear the checkbox for
"Enforce access checks for this application"
If you are not using Role based security in your ASP.net code then there is
very little impact in unchecking this.
If you want to leave it checked, then this is the procedure to use:
Navigate to the COM+ Application (same as above) Note there Are 3 folders
and the bottom one is called Roles Right click Roles and pick New Role, and
enter a Name (for example, ASPNet Users) and click OK Expand the New Role,
and right click the Users subfolder and click New->User Type Network Service
in the box and click Check Names (to make sure it matches) and then click OK
Expand the Components folder and right click the OWCSS_Wrapper.SSWrapper and
click Properties Go to the Security Tab, and check the box by ASPNet User in
the list, and click OK.
One last configuration issue. You will need to make sure that the account
that you have setup the COM+ application to run as, has read access to the
directory where you have the VB6 OWC wrapper file. If the user account
doesn't have access to the file, COM+ will be unable to create the object.
Hope this helps,
Nick