Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
As i need a program to performence the localblast from reengineering a computer model for our scientific research, so i wrote a vb.net program. when the program run into the line of start a process object to call a external command on the linux platform, the program throw me an exception:

xieguigang@xieguigang-HP-Compaq-8510w:~/Desktop/Debug$ mono ./c2.exe build -i "/home/xieguigang/Desktop/8004.gbk" -f gbk
[c2.exe, version 1.0.0.0] c2 compiler
Variable 'blastbin' = "/home/xieguigang/blast/bin/"
Variable 'blastdb' = "/home/xieguigang/blast/db/"
Export all CDS sequence from the GenBank file:
"/home/xieguigang/Desktop/8004.gbk"
Missing method .ctor in assembly /home/xieguigang/Desktop/Debug/Bio.Assembly.dll, type System.Runtime.CompilerServices.ExtensionAttribute
Can't find custom attr constructor image: /home/xieguigang/Desktop/Debug/Bio.Assembly.dll mtoken: 0x0a00003c
Data was export to file:
"/home/xieguigang/blast/db//8004.fsa"
Sequence type is proteins...
Call external command to format the target fasta database:
"/home/xieguigang/blast/bin//formatdb -i "/home/xieguigang/blast/db//8004.fsa" -p T"
xdg-open: unexpected option '-i'
Try 'xdg-open --help' for more information.
Job done!

actually the logs out put are comes from the code that shown below, its clearly that the exception is comes from the line of process.start() calling:

VB
Public Shared Sub FormatGBK(GBK As String, Optional Saved As String = "", Optional FileType As FASTATypes = FASTATypes.Protein)
    Dim Process As System.Diagnostics.Process = New System.Diagnostics.Process()

    If FileType = FASTATypes.Protein Then
          Printfn("Export all CDS sequence from the GenBank file:\n  \'%s\'", GBK)
          Dim FASTA As String = ExportAllCDS(GBK, Saved)
          Printfn("Data was export to file:\n  \'%s\'", FASTA)
          Printfn("Sequence type is proteins...")

          Process.StartInfo = Global.c2.LocalBLAST.CommandLines.FormatDb(FASTA, FileType)
          Printfn("Call external command to format the target fasta database:\n  \'%s\'", String.Format("{0} {1}", Process.StartInfo.FileName, Process.StartInfo.Arguments))
          Process.StartInfo.UseShellExecute = True
          Process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
          Call Process.Start()
          Call Process.WaitForExit()
          Printfn("Job done!")
     ElseIf FileType = FASTATypes.Nucleotide Then


the System.Diagnostics.Process object in the statement is not working.....


I know the xdg-open is an application on the linux platform which have the same function as the object ' System.Diagnostics.Process' in vb.net

so how to deal with this situation on the linux platform when i using the vb.net program to call an external command?
Posted
Updated 15-Oct-13 19:20pm
v2
Comments
Sergey Alexandrovich Kryukov 16-Oct-13 0:27am    
Are you using Mono?
—SA
Mr. xieguigang 谢桂纲 16-Oct-13 1:02am    
yes, mono 2.1 on Ubnuntu 13.04
Sergey Alexandrovich Kryukov 16-Oct-13 2:21am    
Very good, thank you for answering.
—SA

1 solution

This code should not even compile. The instance of Process.StartInfo should first be created; Process.Start accepts one or two arguments (if you use , and the method Process.ForExit is not static, should be called with the process instance obtained from previous call.
And so on… I don't even know what to advise. Well… learn the very basic of programming, .NET programming and some of .NET BCL and FCL. At least read original MDSN documentation before writing code:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx[^].

However, I am not sure it can help you, because I am not sure you have any idea of classes, other types and their instances (objects), instance vs. static members and a lot more. Most likely, you need to learn all that.

—SA
 
Share this answer
 
v2
Comments
Mr. xieguigang 谢桂纲 16-Oct-13 1:10am    
no, i think you have misunderstand my code, the process is an object instance as i declare:
Dim Process As System.Diagnostics.Process = New System.Diagnostics.Process()

and the static function generate a process startinfo object instance:
Process.StartInfo = Global.c2.LocalBLAST.CommandLines.FormatDb(FASTA, FileType)

and no any coding error in the program, the problem is just the shell to call the external command on the linux and windows is diferrent.
Sergey Alexandrovich Kryukov 16-Oct-13 2:19am    
Look, can you only show the code which passes through the compiler? You are wasting time.
It it even irrelevant how much I understood. Can't you say that you code compiles?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900