Monday, 23 August 2010

Get ASP.NET Report Viewer to Occupy 100% Height and Width - Crossbrowser!!

If like me you've been pulling your hair out trying to get the Report Viewer to fill page and then got it to work in IE but then broke it in Firefox. Then I think I've found a solution, and it was quite simple. Add your report view to the page...
<reportviewer
    id="ReportViewer1"
    runat="server"
    width="100%"
    height="100%"
    ProcessingMode="Remote">
    <ServerReport
        ReportServerUrl="[ReportServerUrl]" />
</rsweb:ReportViewer>
Then add the following CSS...
<style type="text/css">

html, body, form
{
    width: 100%;
    height: 100%;
    margin:0;
    padding:0;
}

body
{
    overflow-y:hidden;
}

table#ReportViewer1
{
    display:table !important;
}

</style>
You'll also need to remove the DOCTYPE to get it working in IE so it operates in quirks mode. I've not as yet found any problems removing this yet but I'm sure they'll arise!

Thursday, 3 June 2010

Where is the Enum Generic Constraint??

A frustration about the Generics framework in C#.NET is that it's not possible to specify a generic constraint to be any enumeration.
public class SomeClassName where : Enum
{
    // ...
}
A workaround I use to enforce the constraint, although not pretty is below. Unfortunately it will not raise a build error if anyone has any better ideas please let me know.
public class SomeClassName where T: struct
{
    public SomeClassName()
    {
        if (!typeof(T).IsEnum)
        {
            throw new ArgumentException("Parameter T must be of type Enum");
        }
    }
}

Tuesday, 18 May 2010

SQL Server Management Studio Error - Unable to cast COM object

Ever had this error before in SQL Server Management Studio?
Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.VisualStudio.OLE.Interop.IServiceProvider'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{6D5140C1-7436-11CE-8034-00AA006009FA}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). (Microsoft.VisualStudio.OLE.Interop)
Well it had me stumped for a while. I found this forum post on MSDN but following the suggested fix of re-registering actxprxt.dll didn’t work for me. However my chance I just thought I’d try unregistering it first and hey presto it worked. So if you have the same problem run regsvr32.exe –r actxprxy.dll first before registering it again.

Strange!!