Celtic Coding Solutions Blog

Celtic Coding Solutions Blog - for everything computer related

SSRS Error System.InvalidOperationException: Operation is not valid due to the current state of the object.

SSRS 2005 running on Windows Server 2008 R2 had the following errors as reported on SSRS Logs:-

System.InvalidOperationException: Operation is not valid due to the current state of the object.

Seems to possible causes:-

Installation of Security Update for Microsoft .Net Framework 4 on Servers (KB2656351) and also having large number of parameters or form fields in a SSRS report.

Fix

Open Web.Config for ReportManager usual at:-

C:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\ReportManager 

Find <appsettings> in the file and add 2 new keys:-

<add key="aspnet:MaxHttpCollectionKeys" value="10000" />

<add key="aspnet:MaxJsonDeserializerMembers" value="10000" />

So you should see something like:-

<appSettings>

    <add key="ReportViewerServerConnection" value="Microsoft.ReportingServices.UI.WebControlConnection, ReportingServicesWebUserInterface, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />

    <add key="ReportViewerTemporaryStorage" value="Microsoft.ReportingServices.UI.ReportViewerTemporaryStorage, ReportingServicesWebUserInterface, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />

    <add key="aspnet:MaxHttpCollectionKeys" value="10000" />

    <add key="aspnet:MaxJsonDeserializerMembers" value="10000" />

</appSettings>

Also I recommend changing the Web.Config for ReportServer usual at:-

C:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\ReportServer

In this file there is usual no <appsetting> already added so just pop one under the </ConfigSections> part:-

</configSections>

<appSettings>

<add key="aspnet:MaxHttpCollectionKeys" value="10000" />

<add key="aspnet:MaxJsonDeserializerMembers" value="10000" />

</appSettings>

No need to re-start SSRS or IIS, it should just now be fixed.

Installing .Net Assemblies in GAC for Windows Server 2008 r2

I blogged about installing .Net Assemblies in GAC for Windows Server 2008 (Celtic Coding Linky), but for 2008 R2 it no longer works unless you change the Security Policy and re-boot the server (blogs.msdn.com).

This isn't really an option on a live server so I decided to use gacutil.exe.  Yes I abortion pill safety know this is not supported in a live environment but it works and late term abortions when under tight deadlines it is a proper option.

However this server had an old verion under:-

C:\Windows\Microsoft.NET\Framework\v1.1.4322

No problem give it a go in Command Prompt running as an administrator and get the following error:-

Failure initializing gacutil.

 

Looks like a .Net version difference so open gacutil.exe.config and change the following:-

<?xml version ="1.0"?>

<configuration>

    <startup>

        <requiredRuntime version="v1.1.4322"  />

    </startup>

</configuration>

 

To

<?xml version ="1.0"?>

<configuration>

    <startup>

        <requiredRuntime  safemode="true"  imageVersion="v1.1.4322" version="v1.1.4322"  />

    </startup>

    <runtime>

        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

            <publisherPolicy apply="no"/>

        </assemblyBinding>

    </runtime>

</configuration>

 

Now try installing the dll

gacutil /i CCAssembly.dll

 

Assembly successfully added to the cache

Excellent!

Microsoft Master Data Services Web Error when using a specific Network Account for Application Pool

So you have successfully installed and used the Master Data Services Configuration Manager in SQL Server 2012, but when trying to run the web url you get the following error:-

HTTP Error 500.19 - Internal Server Error

The requested page cannot be accessed because the related configuration data for the page is invalid.

Config Error: Cannot read configuration file due to insufficient permissions.

Config File: \\?\c:\Program Files\Microsoft SQL Server\110\Master Data Services\WebApplication\Web.config

Now the only difference in the setup is I order abortion pill am using a Network login for the Application Pool that this MDS Web Application uses.

So bascially this error means that Application Pool user doesn't have permission to read the web.config at:-

C:\Program Files\Microsoft SQL Server\110\Master Data Services\WebApplication\Web.config

 

That is fine, grant it read permission and now we get another error:-

The current identity (AppPoolUser) does not have write access to 'C:\Program Files\Microsoft SQL Server\110\Master Data Services\MDSTempDir'.

OK so again we need to give the Application Pool user write permission to the MDSTempDir directory.

I am using Windows Server 2008 R2 Enterprise but it is boardly the same for most Windows Servers

Open Windows Explorer and locate the folder

Right Click - abortions cost Properties

Select 'Security' Tab

Click 'Advanced'

Click 'Change Permissions...'

Click 'Add'

Locate the user

Click OK

And Select 'Full Control' for permissions

Now run your MDS Web Page and it should look something like:-

SQL Server Hard Drive Performance with SQLIOSIM.exe

If you are having some strange performance issues on SQL Server, I usually like to see how the Hard Drive is performing.  Microsoft released a great tool called SQLIOStress.exe.  However this has now been superseeded with SQLIOSim.exe.  You can download either the x86 or x64bit version from Microsoft.

Bascially all it does is attack the Hard Drive in similar scenarios as SQL Server would. So to run:-

Load SQLIOSim.exe and remove all drives apart from abortion centers the ones where you will have the SQL Database files save e.g. this is the default when I run on my server:-

So just select the files and click remove to get something like:-

Click OK

Then click the top right hand icon to start the test:-

There are plenty of documents on the internet to interpret the result and what they mean.  But I would also recommend downloading the SQLIOSimParser (just search in abortion facts codeplex) as this converts the results file into a simple to read csv file (just open it in Excel).

"Page cannot be found" Running Asp.Net 4 on Windows Server 2003 IIS6

Trying to run Asp.Net code from a Windows 2003 server running IIS 6.0 and I got a lovely "The page cannot be found"? 

This is bizarre as I have installed .Net 4.0 on the server, correctly ran C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe (just encase) and abortion at 6 weeks also abortion information correctly changed the properties of my Web Application to ASP.Net Version 4.0.30319

Looking at the actually Web Page error and I notice 404.2 - Lockdown policy prevents this request.  Ok nice so you can install .Net 4 for Asp.Net code but by default not actually use it?

Next check what extensions are available on the server:- open command line and enter:-
c:\Windows\System32\cscript iisext.vbs /listfile

Notice that C:\Windows\Microsoft.Net\Framework\v4.0.30319\aspnet_isapi.dll has a Zero meaning disabled.

OK to enable just run the following:-
c:\Windows\System32\cscript iisext.vbs /enfile C:\Windows\Microsoft.Net\Framework\v4.0.30319\AspNet_Isapi.dll

And bingo all code working fine now.

Asp.Net Windows Authorisation in IIS7 for Windows Server 2008 and r2

When Kerbos hasn't been setup correctly on a Windows Server 2008 and 2008r2 server, I've noticed a couple of issues when running Asp.Net code in IIS and using Windows Authorisation enabled, anonymouse disabled.

Running the Page locally in IE on the Server works correctly and Windows Credentials are picked up by the Asp.Net code.  However running the Page in IE on a separate machine (via the network) resulted in the following errors:-

"You are not Authorized to view this page"

 

Or "HTTP Error 401"

Running the Page in IE using the IP address of the server instead of the server name worked (probably because it defaults to NTLM instead of abortion price Kerberos).

1.0) Server 2008r2 Fix

When there appears to be an issue with Kerberos on the Network and IIS (as in this case), then we need Web Applications to default to NTLM instead for Windows Authentication pass-through.
The fix for Server 2008r2 is slightly easier than in Server 2008 so this is first.

1.1) Setup Application Pool

This is not 100percent necessary as you can use one of your existing Application Pools; however for demonstration purposes it is easier to create a new one.

Remote onto the Server and load the Internet Information Services (IIS) Manager:-
Select your server (expand using the plus icon)
Select Application Pools

Create a new Application Pool e.g.
Name: ASPNET2
.Net Framework: v2.0
Managed Pipeline: Integrated
Identity: ApplicationPoolIdentity

 

1.2) Setup/Convert to Web Application

Click on your Asp.Net Directory under Sites – Default Web Site.
Right click and "Convert to Web Application" – might already be as the icon will be changed from the standard folder icon.
Make sure our new Application Pool is selected

Click Test Settings and notice the error:-

1.3) Change Folder Settings to allow App Pool Access

The Application Pool is now running under ApplicationPoolIdentity as ASPNET2.  This is visible in the Windows Task Manager on the Server:-

If this user is not visible then open your Web Application in IE on the local server (just click on the "Browse *:80 (Http) in IIS)

Open File Explorer:-
Go to C:\inetpub
Right Click wwwroot - Properties
Security Tab
Click Edit
Click Add
Change location to ServerName (Top of list)
In the "Enter the object names to select" type:-
IIS AppPool\ASPNET2
Click OK

Select ASPNET2 in the "Group or User Names"
Then Tick:-
Read & Execute
List folder contents
Read

1.4) Set Web Application Windows Authorisation

Back in IIS click on authentication icon:-

Enable ASP.Net Impersonation and Windows Authentication:-

 

1.5) Configure Windows Authorisation

Select Windows Authentication and in the Right Hand Menu select Advanced Settings and it should look like the following:-

Close this and next Click "Providers…"
Move NTLM up and then Negotiate is second

Close and restart IIS - all should now work!

2.0) Server 2008 Fix

Server 2008 is slightly different as not all the options are visible.  Therefore follow all the same settings as above for 2008 up until Point 1.3

2.1) Change folder settings to allow App Pool access (Server 2008 method)

In Server 2008 you cannot add the following user to Folder Security as it will not find this user:-
IIS AppPool\ASPNET2

Instead you need to use icacls with the following syntax (open a command line and enter):-
icacls c:\inetpubwwwroot /grant "IIS AppPool\ASPNET2":(OI)(CI)(RX)

When run then in wwwroot folder security you will see ASPNET2 is listed so follow the same instructions as Server 2008r2.

2.2) Configure Windows Authorisation (Server 2008 natural abortion pill method)

The "Providers…" option is not available in IIS for 2008 and so this has to be done manually via modifying the ApplicationHost.config file under:-
C:\Windows\System32\inetsrv\config

Scroll down to your Application and amend using the following details:-

<system.webServer>
  <security>
    <authentication>
      <anonymousAuthentication enabled="false" />
        <windowsAuthentication enabled="true" useKernelMode="true">
          <providers>
            <clear />
            <add value="NTLM" />
            <add value="Negotiate" />
          </providers>
        </windowsAuthentication>
     </authentication>
  </security>
</system.webServer>

Note in 2008r2 you may need to also add the following:-
  <extendedProtection tokenChecking="None" />
this goes below
  <windowsAuthentication enabled="true" useKernelMode="true">

Restart IIS and all should work.

Installing .Net Assemblies in GAC for Windows Server 2008

Windows Server 2008 Server has a lovely feature that stops you adding abortion pill clinic .Net Assemblies (or .Dlls in generally) into the get an abortion GAC - C:\Windows\Assembly even when logged in as Administrator.

Lots of articles on the web discuss turning off the UAC (User Account Control) or changing the Local Policies.  Also using the GacUtil.exe that comes with .Net Framework returns "Unknown Error".

The solution is actually quite easy and doesn't need Server changes or restarts:-

Open Command Prompt as Administrator (Right click, Run as Administrator).
Run 'Explorer %windir%\Assembly' (or 'Explorer c:\Windows\Assembly)

then run another:-
Run 'Explorer %windir%\Assembly'

Using one of the explorer windows navigate to where your assemblies are located and drag and drop them into the Windows Assembly folder (like usual)


This method also works when trying to uninstall Assemblies from the GAC.