Forum Discussion

marin's avatar
marin
Frequent Contributor
14 years ago

How to reference a .NET assembly

Hello all,



I wonder what is the correct way to reference a .NET assembly in a project?

Although I have added a reference to a .NET assembly (Project Properties -> CLR Bridge -> Browse Files...) and saved the project, I do not see assembly as namespace displayed in intellisense when typing "dotNET. "...

Am I missing something?



Many thanks,



Marin
  • marin's avatar
    marin
    Frequent Contributor
    Hello Vladimir,



    thank you very much for attending to this problem of mine, I really appreciate it.

    Your hint about Evaluate and Inspect dialogs is very valuable, thanks for sharing this.

    As for the OleValue: I now see that there is some value there but it is either not correctly displayed in Log window (maybe encoding issue in TC?) ot there was an error on stripping text from the PDF doc...

    See attached screenshot how Watch List shows the OleValue and how Inspect window shows the value as an array.

    I also attached a screenhsot of PDF doc ("TEST.pdf") that I am trying to read text from.



    Thanks again,



    Marin
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Your inspect window is using "Basic View" which means you'll not see all the properties available.  As Vladimir pointed out, what you want to log is not text.value but text.OleValue so you'll need to change your inspect window to use Advanced view (there's a link at the top of the window that allows you to switch to Advanced view).



    I think you are correct in that the watch list is displaying those odd characters due to an encoding difference in TC.  I believe that the Watch list displays only ANSI and not Unicode or UTF-XX values.  So, if the text in the text.OleValue property are of those extended character sets, they may show up as something strange as you displayed.
  • marin's avatar
    marin
    Frequent Contributor
    Hello Robert,



    thanks for the quick reply.

    Unfortunately switching to Advanced properties does not make any difference - same set of properties and methods will be available as it is in Basic view. Outputting text.OleValue will result in empty log (screenshot attached).

    I am wondering if it might be a good idea to save the OleValue to a text file and to se how it looks like there? Is this possible from Test Complete?



    Thanks,



    Marin 
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    You can use aqFile.WriteToTextFile to write output to any text file.  There are actually several ways of achieving the same thing, but that's probably the easiest.



    Have you tried 



    Log.Message(aqConvert.VarToStr(text))




    Or, since the Additional Info supports HTML and other such, try



    Log.Message("Text OleValue in Additional Info", text.OleValue)




    You could also try explicitly



    Log.Message(text.toString())
  • marin's avatar
    marin
    Frequent Contributor
    Hello Robert,



    unfortunately all of the 3 suggested loggings would result in an empty log.

    Also output to file results in those odd chars (see atached screenshot).



    Thanks again,



    Marin
  • Hi Marin,



    Could you please provide us with your sample PDF document and your PDFBox library so that we could better investigate your problem? Unfortunately, I cannot reproduce the issue with my PDF samples. It seems that there is something special with encoding in your PDF document or with your version of PDFBox. It would be much better if we could take a look exactly at your PDF sample. You can post the files here in the thread or submit them to us using the Contact Support form on our web site.



    Thanks in advance.
  • Hi Marin,



    I have reproduced the issue with your sample PDF document. However, it is not really caused by TestComplete's functionality. Actually, the same problem occurs if you try to extract text from your PDF document with PDFTextStripper without using TestComplete. I have attached a simple Java console application that extracts text from the TEST.pdf file by using the PDFBox library in the way similar to your foo scripting routine and outputs the results to the console window. You can run it in the following way:



    1) Extract files (Main.java and run.bat) from the attached PDFTextStripperSample.zip archive to the folder where your pdfbox-app-1.6.0.jar resides. Also, place your TEST.pdf file to the same folder.



    2) In the jdkdir parameter within the run.bat file, specify the fully-qualified path to the bin subfolder of the folder where the Java Development Kit is installed on your computer. Save the changes.



    3) Execute the run.bat batch file to run the application.



    If you run the sample application, you will see that the text extracted from your PDF document by PDFTextStripper and printed to the console window contains only special characters (like when you use PDFTextStripper in TestComplete scripts). These characters correspond to the symbol codes obtained by PDFTextStripper from the specified PDF document. So, TestComplete does not affect the results returned by PDFTextStripper. TestComplete just receives the text from PDFTextStripper as is.



    It looks like the problem is actually caused by some specifics either in the PDFBox library (I'm not sure about it since it is a third-party library), or in your PDF document (the latter is more probable). Actually, I did not face such a problem when I used PDFBox with all my sample PDF documents. I can reproduce the issue only with your PDF document. Perhaps, it is caused by the font encoding used in your PDF document, but unfortunately, I do not know that exactly.
  • marin's avatar
    marin
    Frequent Contributor
    Hello Vladimir,



    sorry for the late answer...

    Once again huge thanks for attending to this problem.

    I have now verified that the problem is indeed with that very test document (or with the way how it was created). I used different PDF printers to check the situation: if created with one PDF printer the stripped text from the PDF doc would contain that odd chars whereas if PDF document was created with another PDF printer stripped text would contain regular characters.

    I also noticed that PDF stripper seems to be quite unreliable when there are various contents in the PDF document. If document contains e.g. a table with text in it, the stripped text would always contain only odd chars.

    Therefore I might need to be looking for a more reliable way to strip text from PDF documents.



    Thanks again for all your help,



    Marin
  • Hello All,



    Can someone please help me resolve the below issue? I am unable to access .Net assembly struct from test complete



    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;



    namespace TestDll

    {

        public class TestClass

        {

        }



        public struct TestStruct

        {

            public string Name { get; set; }

        }



        public struct TestStruct2

        {

            public TestStruct2(string str) : this()

            {

                Name = str;

                Console.WriteLine(str);

            }

            public string Name { get; set; }

        }

    }



    I had created the project in Microsoft Visual Studio 2012.



    Using the CLR Bridge I selected the components. Please find attached the screenshot. When I try to access the Name property in side  TestStruct stuct from Test complete I am unable to do that. I am able to access the from inside TestStruct2 as it has a constructor defined inside it so can access using zctor.



    Please suggest how to access the properties of a struct defined in Visual Studio.