当我在c#.net visual studio 2012中构建应用程序时生成XML文件 [英] XML File is generated when i build an application in c#.net visual studio 2012

查看:104
本文介绍了当我在c#.net visual studio 2012中构建应用程序时生成XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

当我构建一个应用程序时,会在构建路径中生成一个与我的应用程序可执行文件同名的.xml文件。



我打开了xml文件,发现它包含了我写的app.config中的行。



为什么会这样?如何在我的应用程序中嵌入app.config?

实际上,如果我不在部署中复制xml文件,我的应用程序不会打开水晶报告和应用程序暂停。



app的内容。我写的配置:

Hello,
When I Build an application, an .xml file is generated in the build path having a same name as my application executable.

I opened the xml file and found it contains the lines from app.config which I wrote.

why is this so? how can I embed app.config in my application?
Actually if I donot copy the xml file in the deployment my application does not open crystal reports and application halts.

content of app.config which I wrote :

<!--<startup useLegacyV2RuntimeActivationPolicy="true">


  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>-->

  <startup useLegacyV2RuntimeActivationPolicy="true">

  <supportedRuntime version="v4.0"/></startup>





请告诉我一个怎么样的pp.config嵌入在可执行文件中!



Please Let me know how can app.config embedded in the executable!

推荐答案

这不是app.config。您可以很容易地看到,构建会创建文件< my_application_executable_file_name> .exe.config。



您不希望将此文件嵌入可执行模块中。此文件的整个目的是能够修改它,从而修改应用程序的行为,而无需修改可执行文件本身。 (请记住,程序集可以进行签名(在所有情况下都强烈建议部署所有代码),在这种情况下,对可执行模块的任何修改都会使代码模块无法正常运行。)



当然你可以在你的可执行模块中嵌入一些XML文件,但它应该是一些其他文件,XML或不是。为此,请创建.resx资源并使用添加现有文件。添加文件。它将复制同一源代码目录中的文件,将其添加到项目中(具有相应的属性,因此它不会被构建复制到输出目录,因为它应该嵌入),在资源文件中引用。查看自动生成的资源文件。它将使用一些静态属性进行更新,其名称接近您添加的源文件的名称。只需使用它。



-SA
This is not "app.config". As you can easily see, the build creates the file "<my_application_executable_file_name>.exe.config".

You don't want to embed this file in executable module. The whole purpose of this file is to be able to modify it and hence modify the behavior of the application without retouching the executable file itself. (Remember that the assembly can be signed (highly recommended in all cases for all code which is deployed), and in this case any modification of the executable module make code the module non-functional.)

Of course you can embed some XML file in your executable module, but it should be some other file, XML or not. To do so, create a .resx resource and use "add existing file". Add a file. It will copy a file in the same source-code directory, add it to the project (with appropriate property, so it won't be copied to the output directory by the build, as it should be embedded), referenced in a resource file. Look at the auto-generated resource file. It will be updated with some static property with the name close to the name of your source file you added. Just use it.

—SA


这篇关于当我在c#.net visual studio 2012中构建应用程序时生成XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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