Sunday, July 31, 2016

Register and Unregistered DLL & Automation Variables on Windows Server 2012

Hello Friends,

Last week i am working one of the requirement form client regarding FTP in Navision 2009 R2 using Automation variables.


















General Approach – To register a dll - Using cmd

1 – Run cmd as administrator
2 – Go to main C: by using command – cd\
3 – Go to Folder FTPFileManagementWithSSL where your dll is located using command - cd FTPFileManagementWithSSL
4 – Execute Command - tlbexp FTPFileManagementWithSSL.dll /out: FTPFileManagementWithSSL.tlb
5 – Execute Command - "C:\Windows\Microsoft.NET\Framework\v2.0.50727\regasm" /tlb: FTPFileManagementWithSSL.tlb FTPFileManagementWithSSL.dll

6 – Execute Command - "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil" /i FTPFileManagementWithSSL.dll

DLL Registered successfully – Only in those cases where Microsoft SDKs are installed.

But even using above approach I was getting error – “Automation Control was not registered Successfully” when I used Automation variable in code.

Error

---------------------------
Microsoft Dynamics NAV Classic
---------------------------
This message is for C/AL programmers:

Could not create an instance of the OLE control or Automation server identified by
GUID={6B57267D-A9B1-4C21-9360-E350B57C71AF} 2.0:{D70659DB-C298-3D6B-98BC-C369261DD352}:'FTPFileManagementWithSSL'.FTPFileManagementWithSSL.
Check that the OLE control or Automation server is correctly installed and registered.

---------------------------
OK  
---------------------------

Newer Approach – To register a dll - Using cmd and PowerShell – Windows server 2012

1 – Run cmd as administrator
2 – Go to main C: by using command – cd\
3 – Go to Folder FTPFileManagementWithSSL where your dll is located using command - cd FTPFileManagementWithSSL
4 – Execute Command - tlbexp FTPFileManagementWithSSL.dll /out: FTPFileManagementWithSSL.tlb
5 – Run Windows PowerShell as Administrator
6 – Execute Below Command – For Regasm
."C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" -codebase -tlb "C:\FTPFileManagementWithSSL\FTPFileManagementWithSSL.dll"

7 – Execute Below Command – For gacutil
Set-location "c:\FTPFileManagementWithSSL"
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
$publish = New-Object System.EnterpriseServices.Internal.Publish
$publish.GacInstall("c:\FTPFileManagementWithSSL\FTPFileManagementWithSSL.dll")
iisreset


Dll Registered successfully. And When I ran my code using Automation Variable my error got resolved.


























Also if we want to unregister dll from Gac execute below command,
Set-location "c:\FTPFileManagementWithSSL"
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
$publish = New-Object System.EnterpriseServices.Internal.Publish
$publish.GacRemove("c:\FTPFileManagementWithSSL\FTPFileManagementWithSSL.dll")
iisreset

I hope this will help you in future
Thank you for reading

Keep Sharing...Keep Growing...

Debug Next - User for Debugging Web Client Session, Mobile Session, Web Service Session

Hello Friends,

From NAV 2013 version we can debug any kind of session using the debugger.

"Debug Next" can use for debug following session:
  1. Windows Session
  2. Web Service Session
  3. Web Client Session
  4. Mobile Session
  5. Table Session
Let’s get to it!

First, for all of you that don’t know how to launch the debugger, you need to do this by going to the development environment and go to Tools>Debugger>Debug Session…

This will open up a screen similar to this:












Before open "Debug Next" window first put the break point in your code which is going to execute.




















Click on "Debug Next" button (it is doesn't matter that which session are showing in session list because Debug Next is not depend on the session line showing on your page. It will debug next immediate session which are going to hit that debug point )

Wait for web service/mobile session call to execute that code.

System will execute debugger point in Debug Next window.






















I hope it will help you in future.
Keep Sharing ... Keep Growing....

Report Scheduler - Server Side Report Processing

Hello Friends,

NAV use the RDLC reports and it was taken more time when there was usage amount of data.
Reason is that - 
it is client side reporting tool and system has download all the data on client machine (RAM).

Some time it was giving "Out of memory" exception because client computer doesn't have enough RAM space to store data for report.

Customer are always complaining us that system is taking so much time to generate reports output. (some time taking more than 3-4 hours)

IN NAV 2015/2016 version we can use the Report Schedule functionality to generate any report on server side using scheduler.
It was working very fast compare to old method and doesn't give "out of memory exception"


Steps to generate report using Scheduler:

1) Run the Report & Select the applicable value on Request Page






































2) Goto “Print” & “Schedule” 







































3) Select the Report Output & Earlier Start Time




















4) System will automatic create one temporary job queue entry and start it as per define schedule time
















5) Once the report process completed – system will create new notification entry on role center page – New entry created in your Report Inbox
























6) You can open the report output by click on “Show” button



















7) Report Output on your screen























I hope this value help you in future.
Thank you for reading

Keep Sharing...Keep Growing...

Monday, July 25, 2016

VB Script Very Useful Function - RDLC Report

Hello Friends,

I have identify some of the very useful VB Script function in RDLC Report which helps many times to design reports in RTC reports.

 1)      Percentage calculation using function in VB Script code (Copy from standard USA 10048 Report)


In class version there is code in on section trigger to calculate the percentage










Now in RTC we need to create the VB script function for same to calculate the percentage value


Shared Pct as Decimal
Public Function CalcPct(Amount as Decimal, Profit as Decimal) as Decimal
    if Amount <> 0 then
       Pct = 100 * Profit / Amount
    else
       Pct = 0
    end if
    REM Rounding precision = 0.1
    Return ROUND(10*Pct)/10
End Function


In the Textbox expression define the following expression









2)      Get the Unit Cost value by divide Amout by Qty using VB Script Function (Use in Standard NA 10139 Report)
      
 Note:
 If you directly divide the value in expression than RDLC Report is failed to Handle Divide by Zero  exception
 Not Working  ---  IIF(Fields!UnitCost.Value <> 0, Fields!Amount.Value/Field.UnitCost.Value,0)

 Define the function in report:

Public Function CalcUnitCost(Inventory as Decimal, Remaining as Decimal)
    if Remaining = 0 then
        return 0
    end if
    return Inventory/ Remaining
End Function
































Expression: =Code.CalcUnitCost(Sum(Fields!InventoryValue.Value),Sum(Fields!RemainingQty.Value))































3)      Comment in VB Script function

Use the ‘ (single quote) to write comment  in function



































i will update the more useful function very soon.

I hope it will help you in future.

Keep Sharing...Keep  Growing !!!