text: Running into errors when applying Aspose.Note license in SQL CLR function - Aspose.Note Product Family - Free Support Forum - aspose.com
  Running into errors when applying Aspose.Note license in SQL CLR function
  sarahxu June 24, 2017, 6:40pm #1
  I built a very simple class to convert onenote (.one) file into PDF, added the license part also, the process run fine when tested in Console app.
  Then I created a SQL CLR function to call this class , it throws an error below . After troubleshooting, I know it is the apply license code causing this. Without it, the SQL CLR function runs just fine as expected.
  (1)What is the work around here ? How to fix this error ?
  (2) what I am doing is to read from a list of onenote files , then call this SQL CLR function to convert each one of them into PDF , store it somewhere. what is recommended Place to Set the License in the Source Code in my case ?
  This is what I saw on your site:
  " The license needs to be set only once per application or process.
  For desktop applications, its recommended to set the license in the Initialize() method
  of the main form. And for web applications, it should be in global.asax file's Session_Start()
  all the source codes are attached here . And we do have a valid license I believe. Please let me know if you need more info.
  //apply Aspose license
  Aspose.Note.License license = new Aspose.Note.License();
  license.SetLicense("Aspose.Note.lic");
  Document oneFile = new Document(@OneNote_FilePath);
  oneFile.Save(@PDF_New_FilePath, SaveFormat.Pdf);
  – Error in SQL Management Studio when calling the SQL CLR function
  Msg 6522, Level 16, State 2, Line 76
  A .NET Framework error occurred during execution of user-defined routine or aggregate "convert_onenote_to_PDF":
  at .(Assembly )
  at .(String , Assembly )
  at OneNotePDFConverter.NoteBook.BC_ConvertToPDF.BC_Run(String OneNote_FilePath, String PDF_New_FilePath)
  at OneNotePDFConverter.UserDefinedFunctions.run_process(String OneNote_FilePath, String PDF_New_FilePath)
  kashif.iqbal June 24, 2017, 6:40pm #2
  I have tried to reproduce the issue but facing issues while creating the sql assembly in SQL Management Studio. I tried by setting target platform to .NET 2.0 in my project (as suggested by some blogs) but could not succeed.
  Could you please send me a simplified complete project which can be opened, compiled and executed here to create the DLL file? Once the library is created, I will try to create the SQL assembly and test the issue again.
  I am using SQL Server 2014, VS 2015, Windows 7 and class library project targeting platform .NET 2.0.
  sarahxu June 24, 2017, 6:40pm #3
  I have included all my source files, my sample onenote document, screenshot of the ddls needed to register sql assembly and function etc in the zip file. Let me know if you need anything else. I can be reached at 314-359-4840 (cell) if you need to talk. Duo to the flood happening in Missouri right now, I am working from home for a few days.
  Thank you for sharing the details. We are able to reproduce the problem at our end with the latest version of the API. While investigating, we found that there is an error message mentioned in the SQL file you have mentioned that doesn't occur at our end. Can you please share how to reproduce the same error message at our end? We just want to make sure we are not missing something that can make a difference in making this work.
  kashif.iqbal June 24, 2017, 6:40pm #5
  We have tested the scenario again by preparing the fresh environment and observed the issue. It is logged under Id: NOTENET-2265 for further investigation by the product team. You will be automatically notified once any update is received in this regard.
  sarahxu June 24, 2017, 6:41pm #6
  Using the same SQL CLR, same C# class etc that I gave to you yesterday. I noticed two more issues, details below. And the same .one document can be converted fine in Console app.
  I have attached my sample .one file for you to reproduce the error. You need to change the file name in the testing scripts below , ( already changed to sarah_2 here)
  Declare @OneNote_FilePath nvarchar(2000)
  Declare @PDF_New_FilePath nvarchar(2000)
  set @OneNote_FilePath = '\DEVSHRPNTSQL01\G$\Sarah_test\Sarah_2.one';
  set @PDF_New_FilePath = '\DEVSHRPNTSQL01\G$\Sarah_test\Sarah_2_out.pdf';
  select [OneNote].[dbo].[convert_onenote_to_PDF] (@OneNote_FilePath, @PDF_New_FilePath)
  – (Issue 1)
  when converting a .one document with pics , generate error below, but when run in console app, no issues. once the pic is taken off the file, the SQL CLR runs fine. So it seems to me something is missing to load/read/convert the pic ?
  Msg 6522, Level 16, State 2, Line 72
  System.IO.FileNotFoundException: Could not load file or assembly 'zx_30c9d1d6785e41c382999a806199e059, PublicKeyToken=716fcc553a201e56' or one of its dependencies. The system cannot find the file specified.
  at .(Object , ResolveEventArgs )
  at ​ .​ ( ​ )
  at ​ .(SortedList , ​ )
  at ​ .( ​ )
  at ​ .​ …
  – issue (2)
  when using SQL CLR to convert a .one document with multiple pages, no errors but only converted the first page. but when run in console app, no issues, able to convert multiple pages, sub pages and pics nicely.
  sarahxu June 24, 2017, 6:41pm #7
  FYI , this issue below might be related to the unapplied license in SQL CLR. ( since can not do it )
  kashif.iqbal June 24, 2017, 6:41pm #8
  As per evaluation limitations, only two pages are retained while converting to PDF and rest of the pages are deleted. In this case, since applying license raises exception, the evaluation limitations will do apply.
  Regarding the exception raised with images in the document, we are currently investigating the problem at our end and will soon update you about our findings. Ideally, there shouldn't be any exception raised with images in the document.
  kashif.iqbal June 24, 2017, 6:41pm #9
  I have checked Sarah_2.one file by loading it simply into Document object and observed that same exception is raised with and without the license. Therefore it does not seem to be issue with license or SQL CLR function. I have logged this issue under Id: NOTENET-2269 for further investigation by the product team. You will be automatically notified once any update is received in this regard.
  If you have any other issues, please create new thread as it helps in maintaining each issue separately and follow up.
  sarahxu June 24, 2017, 6:41pm #10
  Do you have an estimate of when the items mentioned this thread will be reviewed and fixed by the product team?
  kashif.iqbal June 24, 2017, 6:41pm #11
  As this issue is logged too recently, therefore it is still in queue for analysis by the product team. Once product team analyses it and provides some ETA, we will share it here immediately.
  kashif.iqbal September 1, 2017, 3:01am #12
  @sarahxu,
  This issue has been fixed in the latest version of Aspose.Note for .NET 17.8. Please try it at your end and let us know if we can be of any additional help to you in this regard.