A
Andrew Raastad
Greetings,
Running into a situation here that is a little beyond my grasp. We have a
web-based product which currently configured and targeted for IIS6. We're
in that transition stage where we want to migrate, or at least open it up to
IIS7. Our product gets installed using a custom installer (WinForm
application project) in what I guess you could call three main steps. The
last step does some configuration to IIS setting up domains, mapping DLLs,
setting application extensions, etc.
The configuration methods use COM Interop by performing late binding to
objects that point to the various properties and such of IIS. For example,
we needed to increase the allotted size for uploading files. The main
method sets an object to be used for this and then calls a help method:
Dim websvc As Object = GetObject("IIS://localhost/W3svc/1")
SetUploadSize(websvc)
Then the modification is done in a helper method like this:
Private Sub SetUploadSize(ByVal websvc As Object)
Try
'Set Maximum file upload in bytes
If websvc.AspMaxRequestEntityAllowed <= 204800 Then
websvc.AspMaxRequestEntityAllowed = 10485760
websvc.SetInfo()
End If
Catch ex As Exception
Throw New Exception("MicrosoftIIS:SetUploadSize() Failed:" &
vbCrLf & ex.ToString)
End Try
End Sub
This type of process is used to set Application Extensions, handlers for
DLLs, and more. But while this works ok on our Windows 2003 Servers running
IIS6, it blows sky high on a box with IIS7 giving the error:
System.Runtime.InteropServices.COMException (0x800CC801): Exception from
HRESULT: 0x800CC801
at
Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object
o, Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack, Boolean IgnoreReturn)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean
IgnoreReturn)
I do not understand what the problem is let alone how to fix it. I am not
totally certain it is moving from IIS6 to IIS7 that is the cause but maybe
from Windows Server 2003 to Server2008/Vista?? Your thoughts, suggestions??
On a side note....
Doing additional research it was pointed out to me that there is an
alternative way to accomplish this - using the System.DirectoryServices
Namespace
(http://msdn.microsoft.com/en-us/library/system.directoryservices.aspx) but
I am having trouble gleaning anything from it that is like what I need to do
here. A second site that was pointed out to me
(http://www.codersource.net/csharp_iis_metabase.html) describes with some
code how to access the IIS MetaBase, but it really doesn't go into all that
much detail on how to accomplish much beyond adding/deleting a virtual
directory or file. While this looks to do the virtual directory items I
need, how do I set DLL Handlers, Application Extensions, modify the allowed
upload size, etc.?
Is there a class or set of classes I can import into the project that
'simplifies' the manipulation or configuration of IIS?
Never having messed with IIS outside the IIS Manager before, I guess I am
just feeling a bit overwhelmed here. Your help and input is greatly
appreciated!
-- Andrew
Running into a situation here that is a little beyond my grasp. We have a
web-based product which currently configured and targeted for IIS6. We're
in that transition stage where we want to migrate, or at least open it up to
IIS7. Our product gets installed using a custom installer (WinForm
application project) in what I guess you could call three main steps. The
last step does some configuration to IIS setting up domains, mapping DLLs,
setting application extensions, etc.
The configuration methods use COM Interop by performing late binding to
objects that point to the various properties and such of IIS. For example,
we needed to increase the allotted size for uploading files. The main
method sets an object to be used for this and then calls a help method:
Dim websvc As Object = GetObject("IIS://localhost/W3svc/1")
SetUploadSize(websvc)
Then the modification is done in a helper method like this:
Private Sub SetUploadSize(ByVal websvc As Object)
Try
'Set Maximum file upload in bytes
If websvc.AspMaxRequestEntityAllowed <= 204800 Then
websvc.AspMaxRequestEntityAllowed = 10485760
websvc.SetInfo()
End If
Catch ex As Exception
Throw New Exception("MicrosoftIIS:SetUploadSize() Failed:" &
vbCrLf & ex.ToString)
End Try
End Sub
This type of process is used to set Application Extensions, handlers for
DLLs, and more. But while this works ok on our Windows 2003 Servers running
IIS6, it blows sky high on a box with IIS7 giving the error:
System.Runtime.InteropServices.COMException (0x800CC801): Exception from
HRESULT: 0x800CC801
at
Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object
o, Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack, Boolean IgnoreReturn)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean
IgnoreReturn)
I do not understand what the problem is let alone how to fix it. I am not
totally certain it is moving from IIS6 to IIS7 that is the cause but maybe
from Windows Server 2003 to Server2008/Vista?? Your thoughts, suggestions??
On a side note....
Doing additional research it was pointed out to me that there is an
alternative way to accomplish this - using the System.DirectoryServices
Namespace
(http://msdn.microsoft.com/en-us/library/system.directoryservices.aspx) but
I am having trouble gleaning anything from it that is like what I need to do
here. A second site that was pointed out to me
(http://www.codersource.net/csharp_iis_metabase.html) describes with some
code how to access the IIS MetaBase, but it really doesn't go into all that
much detail on how to accomplish much beyond adding/deleting a virtual
directory or file. While this looks to do the virtual directory items I
need, how do I set DLL Handlers, Application Extensions, modify the allowed
upload size, etc.?
Is there a class or set of classes I can import into the project that
'simplifies' the manipulation or configuration of IIS?
Never having messed with IIS outside the IIS Manager before, I guess I am
just feeling a bit overwhelmed here. Your help and input is greatly
appreciated!
-- Andrew