Using a Function from a Custom assembly - An unexpected error occurred while compiling expressions. Native compiler return value: â[BC40000]
LocalReport, SQL 2005, Custom Assembly compiled in Framework 2.0, with this I can add the reference to the report.
Client (WinForm Framework 4.0) In the same path of my application, I have the custom assembly (that uses the report)
When I try to get the DataSources, getParameters, or SetParameters, I always get the same error. The LoadDefinition(stream) does not load anything. Any Idea?
An unexpected error occurred while compiling expressions. Native compiler return value: ‘[BC40000] 'RequestMinimum' is obsolete: 'Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See
http://go.microsoft.com/fwlink/?LinkID=155570 for more information.'.’.
I also tried to enable the NetFx40_LegacySecurityPolicy in the config of my application, and nothing change.
If I don't use the Function from the custom assembly I don't have any problem.
Thanks in advance.
October 12th, 2010 3:30pm
Hi luisnike19,
From the error message "'RequestMinimum' is obsolete: 'Assembly level declarative security is obsolete and is no longer enforced by the CLR by default.", it seems 'RequestMinimum' is used in the assembly.
Could you please try to use SecurityAction.Assert instead to check if the issue is solved?
Or, if possible, could you please post the code? It can help us to solve the issue if we can reproduce the issue in-house.
Thanks,
Jin ChenJin Chen - MSFT
Free Windows Admin Tool Kit Click here and download it now
October 13th, 2010 7:52am
Thanks for the reply Jin Chen
First I thought it was the assembly, and then I moved all the class that was in the custom assembly to the report (Report -> Properties -> Code) I didn't make any instance of the class in the SSRS project. And I'm getting exactly the same exception.
So with this, I think that the problem could be in the code (that is in VB, before in the assembly it was in C#) of the in the Report when calling the function,
This is the code of the custom aasembly that now it's in the report. It's simple just to make a custom format of the currencies. In the report I don't have any reference to other assembly.
Public Class SSRS
#Region "Public Methods"
Public Shared Function Format(amount As Decimal, currencySymbol As String, decimalDigits As Integer, decimalSeparator As String, groupSeparator As String, positiveSign As String, _
negativeSign As String, positivePattern As Integer, negativePattern As Integer) As String
Return InnerFormat(GetFormatInfo(currencySymbol, decimalDigits, decimalSeparator, groupSeparator, positiveSign, negativeSign, _
positivePattern, negativePattern), amount)
End Function
#End Region
#Region "Private Methods"
Private Shared Function InnerFormat(formatInfo As NumberFormatInfo, amount As Decimal) As String
Try
Return amount.ToString("C", formatInfo)
Catch
Return amount.ToString()
End Try
End Function
Private Shared Function GetFormatInfo(currencySymbol As String, decimalDigits As Integer, decimalSeparator As String, groupSeparator As String, positiveSign As String, negativeSign As String, _
positivePattern As Integer, negativePattern As Integer) As NumberFormatInfo
Dim formatInfo As New NumberFormatInfo()
formatInfo.CurrencySymbol = currencySymbol
formatInfo.CurrencyDecimalDigits = decimalDigits
formatInfo.CurrencyDecimalSeparator = decimalSeparator
formatInfo.CurrencyGroupSeparator = groupSeparator
formatInfo.PositiveSign = positiveSign
formatInfo.NegativeSign = negativeSign
formatInfo.CurrencyPositivePattern = positivePattern
formatInfo.NumberNegativePattern = negativePattern
Return formatInfo
End Function
#End Region
End Class
To reproduce it a have a simple class
this
.reportViewer1.LocalReport.ReportPath =
this.textBox1.Text;
MessageBox.Show(this.reportViewer1.LocalReport.GetParameters().Count.ToString());
// Or GetDataSourceNames
If the report don't have the function/Code,
I don't have problems with this.
Thanks, luisnike19
October 13th, 2010 10:11am
Has anyone ever resolve this issue? I'm having the same problem.
I'm creating an RDLC stream by instantiating a Microsoft.ReportingServices.RdlObjectModel.Report, setting the Code property, and returning the stream using the RdlSerializer.
Then I'm passing that stream to the ReportViewer like so:
ReportViewer1.LocalReport.LoadReportDefinition(rdlcStream);
If I don't set the Code property, I don't get any errors, but when I set the Code property for a report that needs custom code, I get the above mentioned "'RequestMinimum' is obsolete" error.
Free Windows Admin Tool Kit Click here and download it now
November 8th, 2011 3:16pm
In my case, problem was due I remove "Fields!" of some expressions that have reference to a field in dataset.
I hope you found this helpful.Jim Vzquez Castn
July 25th, 2012 10:06am