Showing a file from the RTC client

ChielChiel Member Posts: 32
edited 2013-09-02 in NAV Three Tier
Hello Everybody
I'm having the following issue when I use the "dotnet" variable "System.Diagnostics.Process" which is located in the assembly:'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.Process.

The following code is used:
Process := Process.Process; //(This variable process runs on the client)
Process.Start('c:\temp\test.txt')

The purpose of the code is to show the file from the rtc client.

The exception which i'm receiving is:

Microsoft Dynamics NAV
Dit bericht is bestemd voor C/AL-programmeurs: De aanroep van lid Start is mislukt: Method 'System.Diagnostics.Process.Start' not found.
OK

Comments

  • mohana_cse06mohana_cse06 Member Posts: 5,504
    i hope you are aware of this
    RTC will search for file in Service Tier system path c:\temp\test.txt not in client system path.
  • ChielChiel Member Posts: 32
    Yes, i'm aware of that.
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    so your file is located in service tier systems path c:\temp\test.txt?
  • ChielChiel Member Posts: 32
    The is located on the client. The dotnet variable has the property RunOnClient=Yes, The exception is: Method 'System.Diagnostics.Process.Start' not found.
  • kinekine Member Posts: 12,562
    For me this is working without problems:
    Proc.Start('somefileonlocaldisc');
    
    where the Proc is the DotNet class System.Diagnostic.Process with RunOnClient=Yes. The Start is static method, you do not need to use the constructor to create the variable...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • ChielChiel Member Posts: 32
    Hello Kine
    I'm receiving this exception:
    (Dutch)
    Microsoft Dynamics NAV
    De DotNet-variabele is niet geïnstantieerd.
    OK
    Translates to ENU
    The DotNet Variable has not been created (something like that)

    I already put the code in a assembly which resolved the problem.
    By the way, which assembly did you use?
  • kinekine Member Posts: 12,562
    I have used the System assembly, class System.Diagnostic.Process.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Guybrush_ThreepwoodGuybrush_Threepwood Member Posts: 28
    I have the same problem. I want to open an Explorer-Window out of a Page in the RoleTailored Client. If I use Automation (per Windows Script Host Object Model) it all works fine, except that annoying Security-Warning. Then i heared, that if i use DotNet, i can skip this Warning by setting "serviceprincipalnamerequired" to "true" in the clientusersettings.config. So i decided to try to start the Explorer per DotNet.

    After a short search i find out, that "System.Diagnostics.Process" should be suitable for my needs. So i created a DotNet-Variable "Process" ('System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.Process) with "RunOnClient=Yes" and tried to run it on the "OnAssistEdit"-Trigger on my Page.
    Process := Process.Process();
    Process.Start('explorer.exe');
    

    But when i click on the AssistEdit i get following Error-Message: "Method 'System.Diagnostics.Process.Start' not found".

    I'm not very familiar with DotNet-Programming, so i created a simple Console-Application in Visual Studio 2010, that should do the same.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Diagnostics;
    
    namespace ConsoleApplication2
    {
        class Program
        {
            static void Main(string[] args)
            {
                Process.Start("explorer.exe");
            }
        }
    }
    

    When i start this simple Application, a new Explorer-Window opens on my Computer. So, basically, i think i did nothing wrong in Navision. But why did i get the Error-Message in NAV? Must i do some more setup in NAV to get it running?
  • deV.chdeV.ch Member Posts: 543
    Are you running the original build of 2009 R2? The one from the dvd? If so, try to use a newer one (newest) because there were issues with .net interop and the early builds. I can run the code with no problem on my environment, i use Build32900.
  • Guybrush_ThreepwoodGuybrush_Threepwood Member Posts: 28
    deV.ch wrote:
    Are you running the original build of 2009 R2?

    Yes, i do use the original build of R2. Sorry, i should have mentioned NAV Version and build in my initial post. :oops: I will try a newer build these days (when i finished setting up a testing environment) and post the results here.

    Thanks for the hint!
  • Guybrush_ThreepwoodGuybrush_Threepwood Member Posts: 28
    I updated my R2 installation to Build 33997 and, suddenly, the same two lines of code work! Thank you very much!

    :thumbsup:
  • KlaasFeenstraKlaasFeenstra Member Posts: 35
    Hello,

    I got the same error. I solved it as follows:


    proc := proc.Process;
    proc.StartInfo.FileName := filename;
    proc.Start;
  • DuikmeesterDuikmeester Member Posts: 308
    I found the following working quite well:

    Process@11020701 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.Process" RUNONCLIENT;
    ProcessStartInfo@11020700 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.ProcessStartInfo" RUNONCLIENT;

    Name := 'notepad.exe';
    Parameters := 'c:\temp\temp.txt';

    ProcessStartInfo := ProcessStartInfo.ProcessStartInfo(Name,Parameters);
    Process := Process.Start(ProcessStartInfo);
    Process.WaitForExit;
    VarExitCode := Process.ExitCode;
  • KlaasFeenstraKlaasFeenstra Member Posts: 35
    Hello Duikmeester,

    I assume that your solution only works with Notepad. I had to use a solution that works with all kind of documents. My solution doesn't need the update for NAV 2009. It works on NAV 2009R2 build 32012.

    Mvg,

    Klaas
Sign In or Register to comment.