类型或名称空间“找不到文件". [英] type or namespace 'file could not be found.'

查看:112
本文介绍了类型或名称空间“找不到文件".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public virtual void simulation()
	{

		try
		{
			   startTime = DateTimeHelperClass.CurrentUnixTimeMillis();

			string[] newFile = SplitFile.splitFile(new File(data), 2);

			Console.WriteLine("Slaves connected in sequencial");
			NewFileSplit nfs = new NewFileSplit();
			nfs.fileSplit(newFile[0], noOfSlaves / 2);

			Console.WriteLine("Slaves connected in Parllel");
			Filesplit fs = new Filesplit();
			fs.fileSplit(newFile[1], noOfSlaves - (noOfSlaves / 2));
			int fileCount = 0;
			for (int i = 0; i < noOfSlaves - (noOfSlaves / 2); i++)

			{



				MyThread m = new MyThread(newFile[1] + "_" + ++fileCount, noOfSlaves - (noOfSlaves / 2));

				m.Start();



			}





		}

		catch (Exception e)

		{

			Console.WriteLine(e);

		}





	}




m.start出现错误,请考虑使用文件名空间.请帮助我.




m.start have error and consider filenamespace.please help me.

推荐答案

我们在那里真的不能给您太多帮助-太远了取决于我们的数据,以便我们为您修复.

因此,您需要使用调试器.
在行上放置一个断点
We can''t really help you too much there - it''s far, far too data dependant for us to fix it for you.

So, you need to use the debugger.
Put a breakpoint on the line
m.Start();


也可能值得打破上面的界限:


It is probably worth breaking the line above it as well:

string cmd = newFile[1] + "_" + ++fileCount;
MyThread m = new MyThread(cmd, noOfSlaves - (noOfSlaves / 2));


并在调试器中运行程序,直到遇到断点并停止.
现在,通过检查"cmd"字符串来确切地了解您要执行的操作.
检查名称是否与您期望的名称完全相同,并且所引用的文件是否与指定的名称完全相同-并包含扩展名(如果有).

至少到那时,您将对为什么它不起作用有一个更好的了解,并且可以开始进行反向工作以找出原因.
但是,直到获得这些信息,每个人都只是在猜测.

[edit]行分隔符上的脑故障:已修复-OriginalGriff [/edit]


And run your program in the debugger until it hits the breakpoint and stops.
Now, look at exactly what you are about to ask it to do by inspecting the "cmd" string.
Check the name is exactly what you expect and that the file it refers to exists exactly as specified - and that includes the extension (if any).

At least then you will have a better idea of why it is not working, and can start working backwards to find out why.

But until you have that information, everybody is just guessing.

[edit]Brain failure on the line split code: fixed - OriginalGriff [/edit]


让我告诉您一个不相关的修复(很抱歉,您没有回答您的主要问题;对此我有评论我解释了为什么它没有制定出负责任的方式):
Let me tell you one unrelated fix (sorry for not answering your main question; in my comment to it I explain why it is not formulated the way to be answerable):
Console.WriteLine(e);

无法正常工作.它只会显示异常类型.要显示更多信息,请执行类似
的操作

won''t work. It will only show exception type. To show something more informative, do something like

Console.WriteLine("{0}: {1}", e.GetType().Name, e.Message);

请参阅:
http://msdn.microsoft.com/en-us/library/system.object. gettype.aspx [^ ],
http://msdn.microsoft.com/en-us/library/system.exception. message.aspx [ ^ ]
http://msdn.microsoft.com/en-us/library/828t9b9h%28v = vs.110%29.aspx [ ^ ].

此外,您绝对不应在过于本地的环境中处理异常.异常通常应与代码隔离,这是异常背后的主要思想之一.在大多数情况下,请放手.异常应该在调用堆栈之间传播,并且仅在很少几个您真正知道如何处理它们的策略选择点中进行处理.

—SA

Please see:
http://msdn.microsoft.com/en-us/library/system.object.gettype.aspx[^],
http://msdn.microsoft.com/en-us/library/system.exception.message.aspx[^]
http://msdn.microsoft.com/en-us/library/828t9b9h%28v=vs.110%29.aspx[^].

Besides, you should not handle exception at all in too local context. Exceptions should mostly be isolated from code, this is one of the main ideas behind exceptions. In most cases, just let go. Exception should be propagated across call stack and handled only in very few strategically chosen points where you really know how to handle them.

—SA


这篇关于类型或名称空间“找不到文件".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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