From: Ed on
Hi Guys,

I am currently trying to complete a dynamic report in MS Reporting
Services for MS CRM4.0. The problem at hand is that it seems almost
impossible to case a QueryString value from MS CRM to the report
within the IFrame that the report exists in. Here is the code I am
currently using to get the Request.QueryString value. In this example
I am trying to get the value for CaseNumber.

Private Dim _results As String = GetRequestQueryString()

Public ReadOnly Property _result() As String
Get
Return _results
End Get
End Property

Public Shared Function GetRequestQueryString() As String
'Web Permisissions
'Dim _regEx As New System.Text.RegularExpressions.Regex("http://
MLMGB/MLM/.*")
'Dim _webPermission As System.Net.WebPermission = New
System.Net.WebPermission(System.Net.NetworkAccess.Connect, _regEx)
'_webPermission.Assert()

'Security Permissions
'Dim _securityPermission As
System.Security.Permissions.SecurityPermission = New
System.Security.Permissions.SecurityPermission(Security.Permissions.PermissionState.Unrestricted)
'_securityPermission.Assert()

'Network Credentials
'Dim _networkCredentials As New
System.Net.NetworkCredential("Administrator", "P(a)ssword", "MLM")
'Dim _credentialCache As New System.Net.CredentialCache()
'_credentialCache.Add(New Uri("http://MLMGB:800/MLM/"), "Full",
_networkCredentials)

Dim _uri As Uri = New Uri("http://MLMGB:80/MLM/",
System.UriKind.RelativeOrAbsolute)
Dim _webRequest As System.Net.WebRequest =
CType(System.Net.WebRequest.Create(_uri), System.Net.HttpWebRequest)
Dim _prefix As String = "http://*:80/MLM/"
Dim _httpListener As New System.Net.HttpListener()
Dim _httpListenerContext As System.Net.HttpListenerContext =
Nothing
Dim _httpListenerRequest As System.Net.HttpListenerRequest =
Nothing
_httpListener.Prefixes.Add(_prefix)
_httpListener.Start()
_httpListenerContext = _httpListener.GetContext()
_httpListener.Stop()
_httpListener.Close()

Dim _nameValueCollection As New
System.Collections.Specialized.NameValueCollection
_nameValueCollection = _httpListenerContext.Request.QueryString
Dim _queryStringResult() As String =
_nameValueCollection.GetValues("CaseNumber")
Dim _result As String = Nothing

If Not _nameValueCollection.GetValues("CaseNumber") Is Nothing Then
_result = _queryStringResult.GetValue(0)
Else
_result = "0"
End If

Return _result
End Function

Here is the URL that is being used:

http://localhost/MLM/crmreports/viewer/viewer.aspx?id={E9FC971D-6911-DF11-B2FE-00155DC5EE00}&helpID=Job%20Cards.rdl&action=filter&CaseNumber=3000215

Another problem here is that I get a permission error as follows:

Failed to load expression host assembly. Details: Request for the
permission of type 'System.Security.Permissions.SecurityPermission,
mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed.

As this is urgent the best possible solution to get this working ASAP
will be appreciated.