IIS 7 Actions, Could not connect to the IIS Server to retrieve list

Hi,

I was trying to use the IIS 7 action to delete a virtual directory, but I am unable to get it to work.  I've tried all the different permutations of options  on the Server tab, but no matter what I do the Website options tab comes back with an exception when I try to drop down either website index or website name.  I tried setting these to 1 and Default Web Site, but when I run the action it says "Could not establish connection to IIS server.  Invalid namespace."  I tried some of the other IIS 7 actions and same result.  I am using Win2k8 R2 Standard 64bit.  I can see the default website on http://localhost:80

 

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

FinalBuilder

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

Could not connect to the IIS server to retrieve list of web site indexes. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Management.ManagementException: User credentials cannot be used for local connections 

 

   at System.Management.ThreadDispatch.Start()

 

   at System.Management.ManagementScope.Initialize()

 

   at System.Management.ManagementScope.Connect()

 

   at IIS.Actions.IIS7.API.Connection.CreateManagementScope(String hostname, ConnectionOptions connectionOptions)

 

   at IIS.Actions.IIS7.BaseIIS7Action.GetWebsiteIndexes(Object value)

 

   --- End of inner exception stack trace ---

 

   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)

 

   at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)

 

   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)

 

   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

 

   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)

 

   at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)

 

System.Management.ManagementException: User credentials cannot be used for local connections 

 

   at System.Management.ThreadDispatch.Start()

 

   at System.Management.ManagementScope.Initialize()

 

   at System.Management.ManagementScope.Connect()

 

   at IIS.Actions.IIS7.API.Connection.CreateManagementScope(String hostname, ConnectionOptions connectionOptions)

 

   at IIS.Actions.IIS7.BaseIIS7Action.GetWebsiteIndexes(Object value)

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

OK   

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

 

Hi Nelson

If this is a local connection could you please try leaving the connection credentials blank. As the exception states ‘User credentials cannot be used for local connections’.

Please let me know if this works or not.

Regards,
Steve

Hi Steve,

Leaving them blank still returns the same “Could not establish connection to IIS server. Invalid namespace”.

I’m not sure what I did to get the above exception, but now I’m getting this exception:


---------------------------
FinalBuilder
---------------------------
Could not connect to the IIS server to retrieve list of web site indexes. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.Management.ManagementException: Invalid namespace

at System.Management.ThreadDispatch.Start()

at System.Management.ManagementScope.Initialize()

at System.Management.ManagementScope.Connect()

at IIS.Actions.IIS7.API.Connection.CreateManagementScope(String hostname, ConnectionOptions connectionOptions)

at IIS.Actions.IIS7.BaseIIS7Action.GetWebsiteIndexes(Object value)

— End of inner exception stack trace —

at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)

at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)

at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)

at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)

at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)

System.Management.ManagementException: Invalid namespace

at System.Management.ThreadDispatch.Start()

at System.Management.ManagementScope.Initialize()

at System.Management.ManagementScope.Connect()

at IIS.Actions.IIS7.API.Connection.CreateManagementScope(String hostname, ConnectionOptions connectionOptions)

at IIS.Actions.IIS7.BaseIIS7Action.GetWebsiteIndexes(Object value)
---------------------------
OK
---------------------------

Hi Nelson,

Make sure you have the IIS ‘Web Management Tools’ feature enabled on the machine (Control Panel -> Programs and Feature).

Regards,
Paul.

The closest thing I found is “Web Server (IIS) Tools” which is already installed. Is that what you mean?

Hi Nelson

Can you please check that you have installed the ‘IIS Management Scripts and Tools’ role on this machine. On Server 2008 you can do this by opening the Server Manager -> Expand Roles -> Select the ‘Web Server (IIS)’ node, the IIS Management Scripts and Tools role is within the management section.

Regards,
Steve

Hi Steve,

Got it! Working as expected now.

If possible, might be nice if the original error message pointed in that direction instead of displaying an exception -Nelson