- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在学习如何将 C# 代码编译成他们自己的 exe 文件。它的工作原理真的很有趣!
到目前为止,我已经有了这个非常小的应用程序,它应该将放入文本框的文本转换为 C# 代码,它有点这样做,但它一直告诉我每次按“构建”时添加引用,但我不知道为什么。
这是源代码:
using Microsoft.CSharp;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
namespace SimpleBuilder
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// store code
/// select what features
/// print out textfile with all the code from the features
/// compile that textfileContent to a exe
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void fakeMessageOne()
{
Messagebox.Show("Hello World");
}
private void button_Click(object sender, RoutedEventArgs e)
{
CSharpCodeProvider csc = new CSharpCodeProvider(new Dictionary<string, string>() { { "CompilerVersion", frameworkTextbox.Text } });
CompilerParameters parameters = new CompilerParameters(new[] { "mscorlib.dll", "System.Core.dll" }, outputTextbox.Text, true);
parameters.GenerateExecutable = true;
CompilerResults result = csc.CompileAssemblyFromSource(parameters, sourceTextbox.Text);
if (result.Errors.HasErrors)
{
result.Errors.Cast<CompilerError>().ToList().ForEach(error => errorTextbox.Text += error.ErrorText + "\r\n");
}
else
{
errorTextbox.Text = "--- Build Succeeded! ---";
}
}
}
}
这是它抛给我的错误
The type or namespace name 'CSharp' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
The type or namespace name 'CodeDom' does not exist in the namespace 'System' (are you missing an assembly reference?)
The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?)
The type or namespace name 'Window' could not be found (are you missing a using directive or an assembly reference?)
我试图在我的应用程序内部编译的代码:
using Microsoft.CSharp;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
namespace SimpleBuilder
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// store code
/// select what features
/// print out textfile with all the code from the features
/// compile that textfileContent to a exe
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void fakeMessageOne()
{
Messagebox.Show("Hello World");
}
}
}
以及它的值(value) here is a image of the small application
最佳答案
您应该将您的引用放入 CompilerParameters.ReferencedAssemblies.Add()
关于c# - 为什么我的应用程序说我缺少引用资料,即使我有引用资料?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39737784/
我正在使用passport.js 为我的node.js 应用程序提供OAuth 身份验证。但我确实有一个疑问: 当我在身份验证时收到配置文件对象(当您定义 OAuth 策略时)时,该对象对于所有提供商
我正在尝试对 wordpress 布局进行解码/逆向工程。我正在浏览 CSS 文件,无法弄清楚这个长长的菜单 mumbo-jumbo 是什么! 我不是要任何人检查代码,而是让我知道我在看什么。这些似乎
所以我尝试制作一个包含私有(private)配置文件的 symfony 项目,并且我使用 FriendsOfSymfony,但是如果我创建两个用户,每个人都可以看到其他人上传的文件。我尝试在多个网站上
我正在编写一个需要使用已登录 G+ 用户的公开个人资料图片的 JS 应用。 如果我有用户 ID,我可以使用 Google+ API 查询个人资料数据。 https://developers.googl
我看过很多关于 facebook 身份验证的帖子,要么是旧的,要么不能正常工作。 然而,最终我在我的项目中做了一些可行但不完全的东西。这是我要求的代码 var facebookAuth
我是一名优秀的程序员,十分优秀!