调试模式与启动无需调试

时间:2015-08-04 08:38:58

标签: c# debugging

每次我在没有调试的情况下启动项目时都会得到System.IO.FileNotFoundException,但是当我调试代码时,一切都很完美。 有谁知道这个问题?我该怎么做才能解决这个问题?

以下是代码:

        try
        {
            var fileContents = System.IO.File.ReadAllText(fileName);
            fileContents = fileContents.Replace("?'", " ");
            System.IO.File.WriteAllText(fileName, fileContents);

            parser = new TextFieldParser(fileName);
            parser.Delimiters = new string[] { "'" };

            while (true)
            {
                segments = parser.ReadFields();
                if (segments == null)
                {
                    break;
                }         

                for (int i = 0; i < segments.Count(); ++i)
                {
                    if (segments[i] == "" || segments[i] == " ")
                    {
                        segments = segments.Except(new string[] {segments[i]}).ToArray();
                    }
                }
                    fillEdifactLetter(segments);                            
            }

            parser.Dispose();
            parser.Close();
        }
        catch (IOException e)
        {
            if (e.Source != null)
                Console.WriteLine("IOException source: {0}", e.Source);
            throw;
        }

谢谢,但它不起作用..

错误消息如下:

Problemereignisname:CLR20r3

Problemsignatur 01:EdifactValidator.exe Problemsignatur 02:1.0.0.0 Problemsignatur 03:55c07efe Problemsignatur 04:mscorlib Problemsignatur 05:4.0.30319.34014 Problemsignatur 06:52e0b679 Problemsignatur 07:451e Problemsignatur 08:ce Problemsignatur 09:System.IO.FileNotFoundException Betriebsystemversion :6.3.9600.2.0.0.256.48 Gebietsschema-ID:3079 Zusatzinformation 1:5861 Zusatzinformation 2:5861822e1919d7c014bbb064c64908b2 Zusatzinformation 3:a10f Zusatzinformation 4:a10ff7d2bb2516fdc753f9c34fc3b069

也许我必须添加&#34; fileName&#34;是一条绝对的道路......

2 个答案:

答案 0 :(得分:1)

检查bin/ReleaseCopy to Output Directory文件夹中是否存在该文件。

如果您尝试访问的文件位于源代码中,则应该在解决方案中编辑文件属性 - 将Copy if newer更改为Copy always$em = $this->getDoctrine()->getManager(); $carousel = $em->getRepository('ApplicationSonataMediaBundle:Gallery')->findOneBy(array('name' => 'Carousel')); $featureProducts = $em->getRepository('MpShopBundle:Product')->findBy(array('status' => 1, 'special' => 1)); $newProducts = $em->getRepository('MpShopBundle:Product')->findBy(array('status' => 1), array('id' => 'ASC'), 8); // pakeisti y DESC $session = $this->getRequest()->getSession(); $skin = $em->getRepository('MpShopBundle:Skin')->findOneBy(array('status' => 1)); return $this->render('MpShopBundle:Frontend:index.html.twig', array( 'featureProducts'=>$featureProducts, 'skin' => $skin, 'newProducts' => $newProducts, 'carousel' => $carousel, ));

答案 1 :(得分:0)

这可能有点简单/明显但我之前通过做一个“干净”然后再重建来解决这个问题。