首页 \ 问答 \ 使用Windows窗体应用程序在C中编译(Compile in C using a Windows Forms Application)

使用Windows窗体应用程序在C中编译(Compile in C using a Windows Forms Application)

我正在使用Visual Studio 2010在C#中创建编译器应用程序。

该程序的目标是在运行时编译用C#或C编写的代码并返回编译结果。

我已经完成了C#部分,但C部分是我遇到的问题。 对于这个,我试图使用Visual Studio命令提示符。 我编写这部分的方式是这样的:

  1. 使用File.Create在C:\中创建.c文件。
  2. 使用进程,打开Visual Studio命令提示符并执行编译。
  3. 捕获输出以将其作为编译结果返回。

但是,它不起作用。 抛出和Win32异常,但我不知道为什么。

我听说过使用gcc的一些事情。 但我想过使用Visual Studio命令提示符作为可能的解决方案。

编辑:我想出了这样做的步骤(我想)。 但是当程序尝试执行process.Start()行时,会出现Win32异常。 我想这可能是一个权限问题,但我真的不知道。


I'm creating a compiler App in C#, using Visual Studio 2010.

The goal of this program is to compile a code written in either C# or C at runtime and return the results of the compilation.

I have done the C# part, but the C part is the one I have problems. For this one, I've tried to use the Visual Studio Command Prompt. The way I'm coding this part is like this:

  1. Create a .c file in C:\ using File.Create.
  2. Using a Process, open the Visual Studio Command Prompt and execute the compilation.
  3. Capture the output to return it as the compilation results.

However, it doesn't work. It throws and Win32 exception, but I don't really know why.

I've heard something about using gcc. But I thought about using the Visual Studio Command Prompt as a possible solution.

EDIT: I figured out the steps to do it (I think). But the Win32 exception appears when the program tries to do the process.Start() line. I guess this might be a permissions problem, but I don't really know.


原文:https://stackoverflow.com/questions/27199253
更新时间:2022-07-30 15:07

最满意答案

您需要根据球体移动方向移动相机位置 -

public GameObject player;
private Vector3 offset;

float distance;
Vector3 playerPrevPos, playerMoveDir;

// Use this for initialization
void Start () {
    offset = transform.position - player.transform.position;

    distance = offset.magnitude;
    playerPrevPos = player.transform.position;
}

void LateUpdate () {

    playerMoveDir = player.transform.position - playerPrevPos;
    playerMoveDir.normalize();
    transform.position = player.transform.position - playerMoveDir * distance;

    transform.LookAt(player.transform.position);

    playerPrevPos = player.transform.position;
}

编辑2:要修复闪烁的相机,试试这个 -

void LateUpdate () {
    playerMoveDir = player.transform.position - playerPrevPos;
    if (playerMoveDir != Vector3.zero)
    {
        playerMoveDir.normalize();
        transform.position = player.transform.position - playerMoveDir * distance;

        transform.position.y += 5f; // required height

        transform.LookAt(player.transform.position);

        playerPrevPos = player.transform.position;
    }
}

You need to move your camera position based on sphere movement direction -

public GameObject player;
private Vector3 offset;

float distance;
Vector3 playerPrevPos, playerMoveDir;

// Use this for initialization
void Start () {
    offset = transform.position - player.transform.position;

    distance = offset.magnitude;
    playerPrevPos = player.transform.position;
}

void LateUpdate () {

    playerMoveDir = player.transform.position - playerPrevPos;
    playerMoveDir.normalize();
    transform.position = player.transform.position - playerMoveDir * distance;

    transform.LookAt(player.transform.position);

    playerPrevPos = player.transform.position;
}

Edit 2: To fix flickering camera, try this -

void LateUpdate () {
    playerMoveDir = player.transform.position - playerPrevPos;
    if (playerMoveDir != Vector3.zero)
    {
        playerMoveDir.normalize();
        transform.position = player.transform.position - playerMoveDir * distance;

        transform.position.y += 5f; // required height

        transform.LookAt(player.transform.position);

        playerPrevPos = player.transform.position;
    }
}

相关问答

更多
  • 你可以在代码中做到这一点,例如 public class FullscreenByDefault : MonoBehaviour { void Start() { Screen.fullScreen = true; } } 或者在任何现有的MonoBehaviour You can do this in code, e.g. public class FullscreenByDefault : MonoBehaviour { void Start() ...
  • C#区分大小写,因此如果这是您的确切代码,则永远不会调用您的函数。 它们需要被称为Start()和FixedUpdate() C# is case sensitive so if this is your exact code your functions will never be called. They need to be called Start() and FixedUpdate()
  • 请提供更多信息 请告诉我你使用的是哪种版本的统一? 您是否已将项目更新为其他最新版本的统一版? 同时给出“标签”数组的屏幕截图。 Please give us more information Please tell me which version of unity you are using? Have you updated the project to some other latest version of unity? Also give a screen shot of your 'tag' ...
  • 您需要根据球体移动方向移动相机位置 - public GameObject player; private Vector3 offset; float distance; Vector3 playerPrevPos, playerMoveDir; // Use this for initialization void Start () { offset = transform.position - player.transform.position; distance = offset ...
  • 每当我尝试只使用controller.Move()时,我的重力函数就会消失 这是文档中所述的预期行为: https : //docs.unity3d.com/ScriptReference/CharacterController.Move.html moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); 而不是从播放器获取输入,请指定您自己的moveDirection 。 例如: mov ...
  • 试试这段代码: public string deviceName; WebCamTexture wct; void Start () { WebCamDevice[] devices = WebCamTexture.devices; deviceName = devices[0].name; wct = new WebCamTexture(deviceName, 400, 300, 12); GetComponent ().material.mainTex ...
  • 结合你的IF 你有最后和最大的支票...... currentDist = Vector3.Distance(transform.position,Player.position) if (currentDist MaxTime) Destroy(th ...
  • 事实证明,问题是云上的构建版本。 构建设置为使用最新的5.5,但项目已升级到5.6。 将云构建更改为使用最新版本5.6后,构建成功 It turned out the issue was the build version on the cloud. The build was set to use the latest 5.5, but the project was upgraded to 5.6. After changing the cloud build to use Latest 5.6, th ...
  • 您是否尝试完全卸载您的应用并在重命名后重新安装,或者您只是尝试重新安装而不删除它? 因为它可以是android维护信息并使用旧的/第一个注册的密钥信息而不是刷新它们。 Did you tried uninstall completely your app and reinstall after rename it or you are just trying to reinstall without remove it? Because it could be android maintaining inf ...
  • 有几种方法可以实现这一点,但我建议使用Raycast。 我认为太阳不仅仅是一个点,它有一些区域可供玩家看到,所以即使他没有看到太阳的中心点,他仍然可以看到它的一部分区域。 如果是这样,我建议向sun对象添加一个新脚本,以便以编程方式识别它。 然后确保它的碰撞器组件的尺寸大约等于太阳。 然后在您想要检测玩家太阳能见度的脚本中,您可以执行以下操作: var ray = Camera.main.ScreenPointToRay(pos); RaycastHit hit; if (!Phy ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)