xdg-open和System.Diagnostics.Process [英] xdg-open and System.Diagnostics.Process
问题描述
因为我需要一个程序来执行localblast为我们的科学研究重新设计计算机模型,所以我写了一个vb.net程序。当程序运行到启动一个进程对象的行来调用linux平台上的外部命令时,该程序给我一个例外:
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编译器
变量'blastbin'=/ home / xieguigang / blast / bin /
变量'blastdb'=/ home / xieguigang / blast / db /
导出GenBank文件中的所有CDS序列:
/home/xieguigang/Desktop/8004.gbk
缺少方法。assembly in assembly /home/xieguigang/Desktop/Debug/Bio.Assembly.dll,输入System.Runtime.CompilerServices.ExtensionAttribute
找不到自定义attr构造函数图像:/ home / xieguigang / Desktop /Debug/Bio.Assembly.dll mtoken:0x0a00003c
数据导出到文件:
/home/xieguigang/blast/db//8004.fsa\"
序列类型是蛋白质......
调用ext用于格式化目标fasta数据库的ernal命令:
/ home / xieguigang / blast / bin // formatdb -i/home/xieguigang/blast/db//8004.fsa-p T
xdg-open:意外选项'-i'
尝试'xdg-open --help'获取更多信息。
工作完成!
实际上输出的日志来自下面显示的代码,显然异常来自process.start()调用的行:
公开 共享 Sub FormatGBK(GBK As String ,可选已保存为 字符串 = ,可选 FileType As FASTATypes = FASTATypes.Protein)
Dim Process As System.Diagnostics.Process = 新 System.Diagnostics.Process()
如果 FileType = FASTATypes.Protein 然后
Printfn( 从GenBank文件导出所有CDS序列:\ n \'%s \',GBK)
Dim FASTA 正如 字符串 = ExportAllCDS(GBK,已保存)
Printfn( 数据导出到文件:\ n \'%s \',FASTA)
Printfn( 序列类型是蛋白质......)
Process.StartInfo = 全局 .c2.LocalBLAST.CommandLines.FormatDb(FASTA,FileType)
Printfn( 调用外部命令格式化目标fasta数据库:\ n \'%s \',字符串 .Format( {0} {1},Process.StartInfo.FileName,Process.StartInfo.Arguments))
Process.StartInfo.UseShellExecute = True
Process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
Call Process.Start()
调用 Process.WaitForExit()
Printfn( 完成工作!)
ElseIf FileType = FASTATypes.Nucleotide 然后
系统tem.Diagnostics.Process对象在声明中不起作用.....
我知道xdg-open是一个应用程序在linux平台上有与vb.net中对象'System.Diagnostics.Process'相同的功能
那么如何在linux平台上处理这种情况当我使用vb.net程序调用外部命令时?
mono ./c2.exe build -i/ home / xieguigang / Desktop / 8004。 gbk-f gbk
[c2.exe,版本1.0.0.0] c2编译器
变量'blastbin'=/ home / xieguigang / blast / bin /
变量'blastdb'=/ home / xieguigang / blast / db /
导出GenBank文件中的所有CDS序列:
/ home / xieguigang / Desktop / 8004.gbk
程序集中缺少方法.ctor /home/xieguigang/Desktop/Debug/Bio.Assembly.dll,输入System.Runtime.CompilerServices.ExtensionAttribute
找不到自定义attr构造函数im年龄:/home/xieguigang/Desktop/Debug/Bio.Assembly.dll mtoken:0x0a00003c
数据导出到文件:
/ home / xieguigang / blast / db //8004.fsa
序列类型是蛋白质......
调用外部命令格式化目标fasta数据库:
/ home / xieguigang / blast / bin // formatdb -i/home/xieguigang/blast/db//8004.fsa-p T
xdg-open:意外选项'-i'
尝试'xdg-open --help'获取更多信息。
工作完成!
实际上是退出的put来自下面显示的代码,很明显异常来自process.start()调用:
公共 共享 Sub FormatGBK(GBK 作为 字符串,可选已保存作为 字符串 = ,< span class =code-keyword>可选 FileType 作为 FASTATypes = FASTATypes.Protein)
Dim Process As System.Diagnostics.Process = New System.Diagnostics.Process()
如果 FileType = FASTATypes.Protein 那么
Printfn( 从GenBank文件导出所有CDS序列:\ n \'%s \',GBK )
Dim FASTA As String = ExportAllCDS(GBK,已保存)
Printfn( 数据导出到文件:\ n \\'%s \',FASTA)
Printfn( 序列类型是蛋白质...)
Process.StartInfo = 全球 .c2.LocalBLAST.CommandLines.FormatDb(FASTA,FileType)
Printfn( 调用外部命令格式化目标fasta数据库:\ n \'%s \ ',字符串 .Format( {0} {1},Process.StartInfo.FileName,Process.StartInfo.Arguments))
Process.StartInfo.UseShellExecute = True
Process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
调用 Process.Start()
调用 Process.WaitForExit()
Printfn( 完成工作!)
ElseIf FileType = FASTATypes。核苷酸然后
语句中的System.Diagnostics.Process对象是不工作.....
我知道xdg-open是linux平台上的一个应用程序,它具有与vb.net中的对象'System.Diagnostics.Process'
所以当我使用vb.net程序调用时如何在linux平台上处理这种情况外部命令?
这段代码甚至不应该编译。首先应创建Process.StartInfo
的实例;Process.Start
接受一个或两个参数(如果使用,方法Process.ForExit
不是静态的,应该用从前一次调用中获得的流程实例调用。
等等......我甚至不知道该建议什么。嗯...学习编程,.NET编程和一些.NET的基础知识BCL和FCL。在编写代码之前至少阅读原始的MDSN文档:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx [ ^ ]。
但是,我不确定它可以帮助你,因为我不确定你是否知道类,其他类型和它们的实例(对象),实例与静态成员等等。很可能,你需要学习所有这些。
-SA
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:
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?解决方案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:
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?
This code should not even compile. The instance ofProcess.StartInfo
should first be created;Process.Start
accepts one or two arguments (if you use , and the methodProcess.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
这篇关于xdg-open和System.Diagnostics.Process的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!