Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Services / Reporting Services / July 2009

Tip: Looking for answers? Try searching our database.

Calling .NET Assemblies in Reporting Services 2008

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Deepankar Neogi - 02 Jul 2009 06:05 GMT
I have been working on Reporting Services 2008 since last few months. During
developing of the reports i had few issues with it which are mentioned below.
I would be glad to get a feedback on the same.

I am trying to call functions from .NET assemblies from reports (sample code
as shown below)

Step# 1:

Report -> Properties -> Code Tab (Get the DNS Name of the machine on which
reports are being viewed)

Public Function GetDNSName() As String
    Try
        Return System.Environment.MachineName
       
    Catch ex As Exception
    Return "Error " & Err.Number & ", from " & ex.Message
    End Try
End Function

Step# 2:

Add a text box on the report. Right Click -> Expressions

=Code.GetDNSName()

Now when i try to view the report i get the following error.

Error 5, Request for permission of type
'System.Security.Permissions.EnvironmentPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicToken=b77a5c561934e089' failed.

What steps should i follow in order to get rid of this error.

Signature

With Warm Regards,
Deepankar Neogi

Patrice - 02 Jul 2009 12:03 GMT
See around :
http://msdn.microsoft.com/en-us/library/bb522723.aspx

Basically you are not allowed to call whatever you want from a report as
those who are allowed to publish reports would be then able to run whatever
code they want server side... I d on't find the exact article but I had to
add an entry in the config file to allow the code I needed (for now I'm
unable to find out the exact article I used).  Here we are the only ones
allowed to publish.

It could be cleaner to gather all this securtity sensitive code to one (or
multiple) assembly and give those asemblies the needed permissions so that
you can stay in control.

--
Patrice

"Deepankar Neogi" <dneogi@syswareinc.com> a écrit dans le message de groupe
de discussion : C2E0BB33-C488-4E8A-BBFF-73068FF53985@microsoft.com...
> I have been working on Reporting Services 2008 since last few months.
> During
[quoted text clipped - 33 lines]
>
> What steps should i follow in order to get rid of this error.
Deepankar Neogi - 02 Jul 2009 12:38 GMT
Thanks Patrice. I have tried out the implmenting the details as mentioned in
the link but i am still getting the same error.
Signature

With Warm Regards,
Deepankar Neogi

> See around :
> http://msdn.microsoft.com/en-us/library/bb522723.aspx
[quoted text clipped - 52 lines]
> >
> > What steps should i follow in order to get rid of this error.
Deepankar Neogi - 02 Jul 2009 12:51 GMT
Also It would be better if you can provide me with the details of the changes
i need to make as I have been fiddling around the with this for quite
sometime now without much success.

Thanks.

Signature

With Warm Regards,
Deepankar Neogi

> See around :
> http://msdn.microsoft.com/en-us/library/bb522723.aspx
[quoted text clipped - 52 lines]
> >
> > What steps should i follow in order to get rid of this error.
Russ Loski - 02 Jul 2009 16:46 GMT
Just a quick note.  Is Patrice on your payroll?  If so, then please take
this offline. If not, then I think that you need to be satisfied with the
little that was provided.

> Also It would be better if you can provide me with the details of the
> changes
[quoted text clipped - 65 lines]
>> >
>> > What steps should i follow in order to get rid of this error.
Patrice - 02 Jul 2009 18:48 GMT
I checked my notes and actually the source I used was :
http://frustrated-developer.blogspot.com/2007/06/deploying-embedded-code-in-repo
rting.html

all along with the doc I mentioned (I agree this is not easy).

As a quick change you could try :
- change the rssrvpolicy.config
- find the CodeGroup entry with Report_Expressions_Default_Permissions with
the name attribute
- change the PermissionSetName attribute from Execution to FullTrust

WARNING : this is only intended to check if this is the issue you are
running into. By doing this you allow users being able to publish reports to
run whatever code they want on your report server...

Starting from this you should be able to  step back to use only what you
really need.  A better optino could be to pack all security sensitive code
in one or multiple assemblies athat are under your control and then grant
rights to those (you'll allow other users to access what you decided they
can access).

--
Patrice

"Deepankar Neogi" <dneogi@syswareinc.com> a écrit dans le message de groupe
de discussion : 136AB56F-6136-4016-AC4D-D30F8A371F29@microsoft.com...
> Also It would be better if you can provide me with the details of the
> changes
[quoted text clipped - 65 lines]
>> >
>> > What steps should i follow in order to get rid of this error.
Deepankar Neogi - 03 Jul 2009 04:27 GMT
I tried the steps as mentioned in the previous post but still get the same
error. Any other solutions to solve this issue.
Signature

With Warm Regards,
Deepankar Neogi

> I checked my notes and actually the source I used was :
> http://frustrated-developer.blogspot.com/2007/06/deploying-embedded-code-in-repo
rting.html
 
[quoted text clipped - 90 lines]
> >> >
> >> > What steps should i follow in order to get rid of this error.
Patrice - 03 Jul 2009 12:09 GMT
I noticed also you are using Err in your catch. Do you have the same problem
if using just Return ex.Message ?

IMO if this is a "Code Access Security" issue it would really work. Else it
could be that you have some other problem with your config...

Waht if you try System.Web.HttpContext.Current.Request.Url.Host instead ?

--
Patrice

"Deepankar Neogi" <dneogi@syswareinc.com> a écrit dans le message de groupe
de discussion : 7EA02EA4-C9FE-4A8C-A756-E39CCCD5304A@microsoft.com...
> I tried the steps as mentioned in the previous post but still get the same
> error. Any other solutions to solve this issue.
[quoted text clipped - 105 lines]
>> >> >
>> >> > What steps should i follow in order to get rid of this error.
Deepankar Neogi - 03 Jul 2009 12:31 GMT
I tried the work around as suggested by you. Changed the code accordingly and
when tried to run the report it gave the error "HTTPContext is not a member
of Web"
Signature

With Warm Regards,
Deepankar Neogi

> I noticed also you are using Err in your catch. Do you have the same problem
> if using just Return ex.Message ?
[quoted text clipped - 118 lines]
> >> >> >
> >> >> > What steps should i follow in order to get rid of this error.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.