编译器错误消息cs0016无法写入输出文件d:\Master \Master.exe。该进程无法访问该文件,因为它被另一个进程使用 [英] compiler error message cs0016 could not write to output file d:\Master\Master.exe.the process can not access the file because it is used by another process

查看:92
本文介绍了编译器错误消息cs0016无法写入输出文件d:\Master \Master.exe。该进程无法访问该文件,因为它被另一个进程使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目将大数据拆分成小数据。母版页就像使用系统一样;使用系统;使用系统;使用系统;
使用System.Threading;
使用System.Collections.Generic;
使用System.Linq;
使用System.Text;
使用System.IO;


名称空间Main1
{
公共类Master
{

内部StreamReader sr;
内部长量;
内部int速度;
内部字符串数据; //品种
内部长记忆; //主内存
internal int mLowEnd;
internal int mHighEnd;
内部长mCpuCap; // master cpu memory
internal int mcLowEnd;
internal int mcHighEnd;
internal int noOfSlaves; //奴隶
内部long smemorycap; //从属内存
internal int sLowEnd;
internal int sHighEnd;
internal int sRandom;
internal int sClustered;
内部长sCpuCap; // slave cpu memory
internal int scLowEnd;
internal int scHighEnd;
internal int scRandom;
internal int scClustered;
内部长启动时间;
内部long endTime;

internal Master()
{
try
{
// sr = new BufferedReader(new InputStreamReader(System.in));

}
catch(例外e)
{
Console.WriteLine(e);
}

}

public virtual void readInput()
{
try
{
Console.WriteLine (体积(输入TB中bigdata的体积):);
volume = Convert.ToInt64(Console.ReadLine());
Console.WriteLine(速度(以bps为单位输入bigdata的速度):);
velocity = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(Variety(输入bigdata的混合,格式由你决定):);
data = Console.ReadLine();
Console.WriteLine(主节点内存(以10GB为增量输入主节点的内存容量范围));
mmemory = Convert.ToInt64(Console.ReadLine());

Console.WriteLine(输入GB的低端:);
mLowEnd = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(以GB为单位输入高端:);
mHighEnd = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(主节点CPU(以10GHz为增量输入主节点的CPU容量范围));
mCpuCap = Convert.ToInt64(Console.ReadLine());
Console.WriteLine(以GHz为单位输入低端:);
mcHighEnd = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(以GHz为单位输入高端:);
mcLowEnd = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(输入从节点数(1 - n):);
noOfSlaves = Convert.ToInt32(Console.ReadLine());

Console.WriteLine(输入连接(分别输入1到n表示1:1到1:n连接):);
Console.WriteLine(输入从节点的内存容量范围,以10GB为增量输入GB的低端:);
smemorycap = Convert.ToInt64(Console.ReadLine());
Console.WriteLine(输入GB的低端:);
sLowEnd = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(以GB为单位输入高端:);
sHighEnd = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(输入内存容量分布(r表示随机,c表示集群):);
Console.WriteLine(random);
sRandom = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(clustered);
sClustered = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(以10GHz的增量输入从节点的CPU容量范围);
sCpuCap = Convert.ToInt64(Console.ReadLine());
Console.WriteLine(以GHz为单位输入低端:);
scLowEnd = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(以GHz为单位输入高端:);
scHighEnd = Convert.ToInt32(Console.ReadLine());

Console.WriteLine(输入CPU容量分布(r表示随机,c表示集群):);
Console.WriteLine(random);
scRandom = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(clustered);
scClustered = Convert.ToInt32(Console.ReadLine());

}
catch(例外e)
{
Console.WriteLine(e);
}

}

public virtual void simulation()
{

try
{
startTime = DateTimeHelperClass.CurrentUnixTimeMillis();

SplitFile.cs.SplitFile sf = new SplitFile.cs.SplitFile();
string [] newFile = sf.fileSplit(data,2);
Console.WriteLine(第一个文件被分成两个文件:+ newFile [0] ++ newFile [1]);
Console.WriteLine(在序列中连接的奴隶);
NewFileSplit nfs = new NewFileSplit();
nfs.fileSplit(newFile [0],noOfSlaves / 2);

Console.WriteLine(在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 m1 = new MyThread(newFile [1] + _ + ++ fileCount, noOfSlaves - (noOfSlaves / 2));

< span class =code-attribute> 主题 t1 = new 线程(() = > MyThread.method(newFile [1] +_+ ++ fileCount,noOfSlaves - (noOfSlaves / 2)));
t1.Start();
// m1.start();

}


}
catch(例外e)
{
Console.WriteLine(e);
}


}

public virtual void viewOutput()
{
try
{


Console.WriteLine(Volume:.....+ volume);
Console.WriteLine(Velocity:.....+ velocity);
Console.WriteLine(主节点内存低端:.....+ mLowEnd);
Console.WriteLine(主节点内存高端:.....+ mHighEnd);
Console.WriteLine(主节点CPU低端:.....+ mcLowEnd);
Console.WriteLine(主节点CPU高端:.....+ mcHighEnd);
Console.WriteLine(从节点数:......+ noOfSlaves);
Console.WriteLine(Connectivity:1:.....);
Console.WriteLine(Slave node memory capacity low end:.....+ sLowEnd);
Console.WriteLine(从节点内存容量高端:.....+ sHighEnd);
Console.WriteLine(从节点内存容量分配:.....+ sRandom +,+ sClustered);
Console.WriteLine(从节点CPU容量低端:.....+ sLowEnd);
Console.WriteLine(从节点CPU容量高端:.....+ scHighEnd);
Console.WriteLine(从节点CPU容量分配:.....+ scRandom +,+ scClustered);
endTime = DateTimeHelperClass.CurrentUnixTimeMillis();

}
catch(例外e)
{
Console.WriteLine(e);
}
}

public virtual void calculataThroughPut()
{
try
{
Thread.Sleep(5000);
// System.out.println(吞吐量(常规):);
double throughput = endTime - startTime;
double throughputCon = 300;
Console.WriteLine(ThroughPut(传统)+ throughputCon);
Console.WriteLine(吞吐量(bigdata):+吞吐量);
Console.WriteLine(加速因子((Thput_Bigdata - Thput_conv)/ Thput_conv):);
double result =((throughput - throughputCon)/ throughputCon);
Console.Write(result);
}
catch(例外e)
{
Console.WriteLine(e);
}
}

public static void Main(string [] args)
{
Master m = new Master();

Thread.Sleep(10000);

m.readInput();
m.simulation();
m.viewOutput();
m.calculataThroughPut();
Console.ReadKey();

}
}
}









使用System; 
使用System.IO;
使用System.Runtime.Remoting.Channels;
使用System.Runtime.Remoting.Channels.Tcp;


/ *
*要更改此模板,请选择工具|模板
*并在编辑器中打开模板。
* /

公共类奴隶
{
内部奴隶()
{
Console.WriteLine(奴隶正在运行);
}
public static void Main(string [] args)
{
try
{
Console.WriteLine(slave is running);
Console.WriteLine(从主文件中恢复文件);
Console.WriteLine(Time+ DateTimeHelperClass.CurrentUnixTimeMillis());
ChannelServices.RegisterChannel(new TcpClientChannel(),true);
MasterImp m =(MasterImp)Activator.GetObject(typeof(MasterImp),tcp:// localhost:8086 / m);
if(m == null)
{
Console.WriteLine(找不到服务器);
返回;
}
else
{
// MasterInt m =(MasterInt)Naming.lookup(rmi:// localhost / master);
长尺寸= m.Size;
string file = m.File;
Console.WriteLine(部分文件是:+文件);
mergeSort ms = new mergeSort();
int [] arry = ms.merge(file);
InsertionSort @is = new InsertionSort();
int [] arry1 = @ is.insertionSort(file);
for(int i = 0; i < arry.Length; i ++)

{

< span class =code-attribute> // System.out.println(arry [i]);

}





< span class =code-attribute>
// System.out.println( file size+ Filesplit.sizeOfFiles);

< span class =code-attribute> Console.WriteLine( file size + size);

< span class =code-attribute> }

}

< span class =code-attribute> catch (例外 e)

{

Console.WriteLine(e);



}



}





< span class =code-attribute>}













首次运行主页后自动运行从页面。奴隶页面错误是这样的。

我的probekm是编译器错误消息cs0016无法写入输出文件d:\Master \Master.exe。该进程无法访问该文件,因为它被使用另一个过程。





请帮帮我

解决方案

这是相当的很可能 Richard C Bishop 的猜测是正确的(请参阅他对该问题的评论) 。通常,这个另一个进程是没有正确关闭文件句柄的相同进程。但它可能是别的东西。你需要对它进行调查。



如何?这并不难。请查看我过去的答案:

如何压缩错误'已经使用过通过vb.net中的另一个进程 [ ^ ],

文件由另一个进程异常使用 [ ^ ]。







顺便说一下有些东西试图修改EXE文件,这很奇怪。你的意思是这样吗?通常,这些文件仅由编译器或病毒修改。除了我上面所写的内容:在加载执行模块时,没有任何东西可以修改任何可执行模块。



-SA

my project is split big data into small data. master page is like as

using System;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace Main1
{
    public class Master
    {

        internal StreamReader sr;
        internal long volume;
        internal int velocity;
        internal string data; //variety
        internal long mmemory; //master memory
        internal int mLowEnd;
        internal int mHighEnd;
        internal long mCpuCap; // master cpu memory
        internal int mcLowEnd;
        internal int mcHighEnd;
        internal int noOfSlaves; //slaves
        internal long smemorycap; //slave memory
        internal int sLowEnd;
        internal int sHighEnd;
        internal int sRandom;
        internal int sClustered;
        internal long sCpuCap; // slave cpu memory
        internal int scLowEnd;
        internal int scHighEnd;
        internal int scRandom;
        internal int scClustered;
        internal long startTime;
        internal long endTime;

        internal Master()
	{
		try
		{
			//sr = new BufferedReader(new InputStreamReader(System.in));

		}
		catch (Exception e)
		{
			Console.WriteLine(e);
		}

	}

        public virtual void readInput()
        {
            try
            {
                Console.WriteLine("Volume (enter the volume of the bigdata in TB):");
                volume = Convert.ToInt64(Console.ReadLine());
                Console.WriteLine("Velocity (enter the velocity of the bigdata in bps):");
                velocity = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Variety (enter the mix of the bigdata, the format to be determined by you):");
                data = Console.ReadLine();
                Console.WriteLine("Master node memory (enter the memory capacity range of the master node in increments of 10GB)");
                mmemory = Convert.ToInt64(Console.ReadLine());

                Console.WriteLine("Enter the low end in GB:");
                mLowEnd = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter the high end in GB:");
                mHighEnd = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Master node CPU (enter the CPU capacity range of the master node in increments of 10GHz)");
                mCpuCap = Convert.ToInt64(Console.ReadLine());
                Console.WriteLine("Enter the low end in GHz:");
                mcHighEnd = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter the high end in GHz:");
                mcLowEnd = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter the number of slave nodes (1 - n):");
                noOfSlaves = Convert.ToInt32(Console.ReadLine());

                Console.WriteLine("Enter the connectivity (enter 1 to n for 1:1 to 1:n connectivity, respectively):");
                Console.WriteLine("Enter the memory capacity range of the slave nodes in increments of 10GB Enter the low end in GB:");
                smemorycap = Convert.ToInt64(Console.ReadLine());
                Console.WriteLine("Enter the low end in GB:");
                sLowEnd = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter the high end in GB:");
                sHighEnd = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter the memory capacity distribution (r for random, c for clustered):");
                Console.WriteLine("random");
                sRandom = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("clustered");
                sClustered = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter the CPU capacity range of the slave nodes in increments of 10GHz");
                sCpuCap = Convert.ToInt64(Console.ReadLine());
                Console.WriteLine("Enter the low end in GHz:");
                scLowEnd = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter the high end in GHz:");
                scHighEnd = Convert.ToInt32(Console.ReadLine());

                Console.WriteLine("Enter the CPU capacity distribution (r for random, c for clustered):");
                Console.WriteLine("random");
                scRandom = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("clustered");
                scClustered = Convert.ToInt32(Console.ReadLine());

            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

        }

        public virtual void simulation()
        {

            try
            {
                startTime = DateTimeHelperClass.CurrentUnixTimeMillis();

                SplitFile.cs.SplitFile sf = new SplitFile.cs.SplitFile();
                string[] newFile = sf.fileSplit(data, 2);
                Console.WriteLine("first file is split into two files:"+newFile[0]+" "+newFile[1]);
                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 m1 = new MyThread(newFile[1] + "_" + ++fileCount, noOfSlaves - (noOfSlaves / 2));

                    Thread t1 = new Thread(() => MyThread.method(newFile[1] + "_" + ++fileCount, noOfSlaves - (noOfSlaves / 2)));
                    t1.Start();
                   // m1.start();

                }


            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }


        }

        public virtual void viewOutput()
        {
            try
            {


                Console.WriteLine("Volume: ....." + volume);
                Console.WriteLine("Velocity: ....." + velocity);
                Console.WriteLine("Master node memory low end: ....." + mLowEnd);
                Console.WriteLine("Master node memory high end: ....." + mHighEnd);
                Console.WriteLine("Master node CPU low end: ....." + mcLowEnd);
                Console.WriteLine("Master node CPU high end: ....." + mcHighEnd);
                Console.WriteLine("Number of slave nodes: ....." + noOfSlaves);
                Console.WriteLine("Connectivity: 1:.....");
                Console.WriteLine("Slave node memory capacity low end: ....." + sLowEnd);
                Console.WriteLine("Slave node memory capacity high end: ....." + sHighEnd);
                Console.WriteLine("Slave node memory capacity distribution: ....." + sRandom + ", " + sClustered);
                Console.WriteLine("Slave node CPU capacity low end: ....." + sLowEnd);
                Console.WriteLine("Slave node CPU capacity high end: ....." + scHighEnd);
                Console.WriteLine("Slave node CPU capacity distribution: ....." + scRandom + ", " + scClustered);
                endTime = DateTimeHelperClass.CurrentUnixTimeMillis();

            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }

        public virtual void calculataThroughPut()
        {
            try
            {
                Thread.Sleep(5000);
                // System.out.println("Throughput (conventional):");
                double throughput = endTime - startTime;
                double throughputCon = 300;
                Console.WriteLine("ThroughPut (conventional)" + throughputCon);
                Console.WriteLine("Throughput (bigdata):" + throughput);
                Console.WriteLine("Speedup factor ((Thput_Bigdata  - Thput_conv)/Thput_conv):   ");
                double result = ((throughput - throughputCon) / throughputCon);
                Console.Write(result);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }

        public static void Main(string[] args)
        {
            Master m = new Master();
           
            Thread.Sleep(10000);
           
            m.readInput();
            m.simulation();
            m.viewOutput();
            m.calculataThroughPut();
	    Console.ReadKey();
            
        }
    }
}





using System;
using System.IO;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

public class slave
{
	internal slave()
	{
		Console.WriteLine("Slave is running");
	}
	public static void Main(string[] args)
	{
        try
        {
            Console.WriteLine("slave is running");
            Console.WriteLine("File reciving from master");
            Console.WriteLine("Time" + DateTimeHelperClass.CurrentUnixTimeMillis());
            ChannelServices.RegisterChannel(new TcpClientChannel(), true);
            MasterImp m = (MasterImp)Activator.GetObject(typeof(MasterImp), "tcp://localhost:8086/m");
            if (m == null)
            {
                Console.WriteLine("Could not locate server");
                return;
            }
            else
            {
                //MasterInt m = (MasterInt)Naming.lookup("rmi://localhost/master");
                long size = m.Size;
                string file = m.File;
                Console.WriteLine("part file is: " + file);
                mergeSort ms = new mergeSort();
                int[] arry = ms.merge(file);
                InsertionSort @is = new InsertionSort();
                int[] arry1 = @is.insertionSort(file);
                for (int i = 0; i < arry.Length; i++)

                {

                    // System.out.println(arry[i]);

                }





                //System.out.println(" file size"+ Filesplit.sizeOfFiles);

                Console.WriteLine(" file size " + size);

            }

        }

        catch (Exception e)

        {

            Console.WriteLine(e);



        }

    

	}





}







first run master after automatically run slave page. slave page error like this.
my probekm is compiler error message cs0016 could not write to output file d:\Master\Master.exe.the process can not access the file because it is used by another process.


please help me

解决方案

It is quite likely that the guess by Richard C Bishop is correct (please see his comment to the question). Very often, this "another process" is the same process which did not properly close a file handle. But it can be something else. You need to investigate it.

How? This is not to hard. Please see my past answers:
how to compress the error 'it is already used by another process' in vb.net[^],
File used by another process exception[^].

[EDIT]

By the way, it's weird that something is trying to modify EXE file. Did you mean to do so? Normally, those files are only modified by compilers or viruses. On top of what I've written above: nothing can modify any executable module when it is loaded for execution.

—SA


这篇关于编译器错误消息cs0016无法写入输出文件d:\Master \Master.exe。该进程无法访问该文件,因为它被另一个进程使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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