确定App是否正在运行是Visual Studio [英] Determine whether App is running is Visual Studio

查看:81
本文介绍了确定App是否正在运行是Visual Studio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有办法吗?


#if APP_IS_RUN_IN_VS

path ="。\..\..\ .. \ myfile.rpt" ;;

#else

path =" myfile.rpt";

#endif


我不想把文件放到debug / bin目录中,因为它们可能会在重建时删除



-

cody


免费工具,游戏和幽默
http://www.deutronium.de.vu || http://www.deutronium.tk

解决方案

如果我们假设您始终使用Debug配置从IDE运行项目



您可以使用以下条件:


#if DEBUG

path ="。\..\..\..\myfile.rpt" ;;

#else

path =" myfile.rpt";

#endif


- < br $>
Dmitriy Lapshin [C#/ .NET MVP]

X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx

将单元测试的强大功能带到VS .NET IDE


" cody" <无**************** @ gmx.net>在消息中写道

新闻:uG ************* @ TK2MSFTNGP12.phx.gbl ...

有没有办法做:

#if APP_IS_RUN_IN_VS
path ="。\..\..\..\myfile.rpt" ;;
#else
path =" myfile.rpt";
#endif

我不想把文件放到debug / bin目录中,因为它们在重建后会被删除。

-

免费工具,游戏和幽默
http://www.deutronium.de.vu || http://www.deutronium.tk



您可以使用:


公共共享函数IsInIDE()作为布尔值


如果System.Diagnostics.Debugger.IsAttached那么


''应用程序当前正在IDE中运行。


返回True


Else


''该应用程序当前正在作为已编译的应用程序运行。


返回错误


结束如果


结束功能

-


HTH


Conseiller首席/高级顾问

Concept S2i inc。( www.s2i.com

" cody" <无**************** @ gmx.net>在消息中写道

新闻:uG ************* @ TK2MSFTNGP12.phx.gbl ...

有没有办法做:

#if APP_IS_RUN_IN_VS
path ="。\..\..\..\myfile.rpt" ;;
#else
path =" myfile.rpt";
#endif

我不想把文件放到debug / bin目录中,因为它们在重建后会被删除。

-

免费工具,游戏和幽默
http://www.deutronium.de.vu || http://www.deutronium.tk


>如果我们假设您总是使用Debug配置从IDE运行

项目

,那么您可以使用以下条件:

#if DEBUG
path ="。\..\..\..\myfile.rpt" ;;
#else
path =" myfile。 rpt" ;;
#endif



但我不能假设这一点。此外,如果应用程序不是在VS中运行
,则仍会设置调试。还有另外一种方法吗?

也许我可以指示VS自动将这些文件复制到bin / obj

目录中,这样就不需要改变路径了,但是如何?


-

cody


免费软件工具,游戏和幽默
http://www.deutronium.de.vu || http://www.deutronium.tk

Is there a way to do:

#if APP_IS_RUN_IN_VS
path = ".\..\..\..\myfile.rpt";
#else
path = "myfile.rpt";
#endif

I don''t want to put the files into debug/bin dir since they woulbe be
deleted on rebuilt then.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk

解决方案

If we assume that you always use the Debug configuration to run the project
from the IDE,
you can use the following condition:

#if DEBUG
path = ".\..\..\..\myfile.rpt";
#else
path = "myfile.rpt";
#endif

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"cody" <no****************@gmx.net> wrote in message
news:uG*************@TK2MSFTNGP12.phx.gbl...

Is there a way to do:

#if APP_IS_RUN_IN_VS
path = ".\..\..\..\myfile.rpt";
#else
path = "myfile.rpt";
#endif

I don''t want to put the files into debug/bin dir since they woulbe be
deleted on rebuilt then.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk




You can use this:

Public Shared Function IsInIDE() As Boolean

If System.Diagnostics.Debugger.IsAttached Then

''The application is currently running from within the IDE.

Return True

Else

''The application is currently running as a compiled application.

Return False

End If

End Function
--

HTH

éric Moreau, MCSD
Conseiller Principal / Senior Consultant
Concept S2i inc.(www.s2i.com)
"cody" <no****************@gmx.net> wrote in message
news:uG*************@TK2MSFTNGP12.phx.gbl...

Is there a way to do:

#if APP_IS_RUN_IN_VS
path = ".\..\..\..\myfile.rpt";
#else
path = "myfile.rpt";
#endif

I don''t want to put the files into debug/bin dir since they woulbe be
deleted on rebuilt then.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk



> If we assume that you always use the Debug configuration to run the
project

from the IDE,
you can use the following condition:

#if DEBUG
path = ".\..\..\..\myfile.rpt";
#else
path = "myfile.rpt";
#endif


But I cannot assume this. Additionally, Debug is still set if the app is not
run in VS. Is there another way?
Maybe I can instruct VS to automatically copy these files into the bin/obj
dirs so there is no need to change the path, but how?

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk


这篇关于确定App是否正在运行是Visual Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆