Forum Discussion

chris_rothermel's avatar
chris_rothermel
Contributor
2 years ago

Referencing C# Workspace Assemblies from VB.Net, Warning Access of ... not evaluated

I found a C# code library and I'd like to use this class in VB.Net.  Here are the steps I've taken so far. 1. In my VB.Net Rule I've referenced the C# assemblies. 2. In my VB.Net Rule I've create...
  • RobbSalzmann's avatar
    2 years ago

    Hi Chris,

    It doesn't matter that your library is written in C#.  Once compiled, .net is .net.
    The error is telling you that you are accessing the shared (static) method XIRR through in instance of CalculationWrapper  - created when you used the New keyword.
     Try this:

     

     

     'Create an object for the class defined in External Assembly (Toolbox) so we can use methods in the class
    '** Commented out.  Don't instantiate to use a static method.
    'Dim XIRRWrapper As New OneStream.BusinessRule.Finance.XIRR.CalculationWrapper
    Dim cashFlows = New List(Of OneStream.BusinessRule.Finance.XIRR.CashFlowDates ) From 
    {
       New OneStream.BusinessRule.Finance.XIRR.CashFlowDates(-1000, New DateTime(2017, 1, 1)),
       New OneStream.BusinessRule.Finance.XIRR.CashFlowDates(500, New DateTime(2017, 7, 1)),
       New OneStream.BusinessRule.Finance.XIRR.CashFlowDates(507.5, New DateTime(2018, 1, 1))
    }
    api.LogMessage(OneStream.BusinessRule.Finance.XIRR.CalculationWrapper.XIRR(cashFlows, 6).ToString())

     

     

     

  • chris_rothermel's avatar
    2 years ago

    Hi Robb,

    Thank you!  The warning is gone.  Business Rule 'XIRRusage' was compiled successfully.

    api.LogMessage( OneStream.BusinessRule.Finance.XIRR.CalculationWrapper.XIRR(cashFlows, 6).ToString() )