我正在尝试使用命令行在Debian上使用Mono编译C#脚本,如下所示:
gmcs Main.cs
Run Code Online (Sandbox Code Playgroud)
但是,我收到以下错误:
Main.cs(6,14): error CS0234: The type or namespace name `Drawing' does not exist in the namespace `System'. Are you missing an assembly reference?
Main.cs(7,14): error CS0234: The type or namespace name `Drawing' does not exist in the namespace `System'. Are you missing an assembly reference?
Main.cs(12,7): error CS0246: The type or namespace name `iTextSharp' could not be found. Are you missing a using directive or an assembly reference?
Main.cs(13,7): error CS0246: The type or namespace name `iTextSharp' …Run Code Online (Sandbox Code Playgroud) 我正在为学校项目开发一个邮件客户端.我已经设法使用SmtpClientC#发送电子邮件.这适用于任何服务器,但它不适用于Gmail.我相信这是因为谷歌使用TLS.我曾尝试设置EnableSsl到true上SmtpClient,但这并不有所作为.
这是我用来创建SmtpClient和发送电子邮件的代码.
this.client = new SmtpClient("smtp.gmail.com", 587);
this.client.EnableSsl = true;
this.client.UseDefaultCredentials = false;
this.client.Credentials = new NetworkCredential("username", "password");
try
{
// Create instance of message
MailMessage message = new MailMessage();
// Add receiver
message.To.Add("myemail@mydomain.com");
// Set sender
// In this case the same as the username
message.From = new MailAddress("username@gmail.com");
// Set subject
message.Subject = "Test";
// Set body of message
message.Body = "En test besked";
// Send the message …Run Code Online (Sandbox Code Playgroud) 我是一个需要尝试编译一些C#代码才能工作的Unix人.我已经下载了Mono for Mac和mcs命令行工具.这个库附带了一个csproj文件,其中包含了我需要编译的所有文件的XML.
Mono/mcs可以读取此csproj文件并从中生成DLL吗?
Mono .NET是否支持并编译C++/CLI?
如果没有,你知道他们是否有任何支持它的计划?
我正在使用C#.net Windows桌面应用程序.我也希望与其他平台一起运行这些应用程序.所以,我使用Mono 2.10作为交叉编译器.运行时,意外地我的应用程序被终止,说错误消息像
错误:无法打开所选文件夹.
无法加载文件或程序集"DocumentFormat.OpenXml.dll,version = 2.0.5022.0,culture = neutral,PublicKeyToken = 31bf3856ad364e35"或其中一个依赖项.
我不知道这里有什么问题...我在c:\ program files\open xml sdk\v2\lib\DocumentFormat.OpenXml.dll上安装了openxml sdk2.0.
并将我的应用程序eXe放在同一个地方进行测试......
请指导我解决这个问题......
我正在尝试创建一个自定义的UIButton UIButtonType.RoundedRect.
我添加的功能正在运行,但是我的按钮的初始圆形边框状态存在问题.我的扩展按钮的边框在点击之后才会被绘制.

更新(2013年1月24日):根据Richard Marskell的要求添加了红色背景测试的结果,该结果仅得出按钮的标签. BackgroundColor = UIColor.Red;

以下是我创建自定义按钮的源代码.
public class TestView : UIView
{
public TestView(IntPtr p) : base(p) { }
public TestView(RectangleF bounds)
{
Frame = bounds;
BackgroundColor = UIColor.White;
UIButton button1 = new UIButton(UIButtonType.RoundedRect);
button1.Frame = new RectangleF(20,20,100,50);
button1.SetTitle("Button 1", UIControlState.Normal);
AddSubview(button1); // Drawn Correctly
MyButton button2 = new MyButton();
button2.Frame = new RectangleF(20,90,100,50);
button2.SetTitle("Button 2", UIControlState.Normal);
AddSubview(button2); // Only drawn correctly after Tap
// EDIT: Added to test Miguel's theory
UIButton button3 = UIButton.FromType(UIButtonType.RoundedRect);
button3.Frame …Run Code Online (Sandbox Code Playgroud) 我想从Visual Studio远程调试在Linux上运行的C#控制台应用程序.这是我到目前为止发现的:
http://www.mono-project.com/Debugger
Mono运行时实现了一个调试接口,允许调试器和IDE调试托管代码.这称为软调试器,MonoDevelop,Xamarin Studio和Visual Studio(安装适当的插件时)以及命令行SDB客户端都支持它.
Mono提供了一个API来与调试器通信,并通过Mono.Debugger.Soft.dll程序集创建自己的调试UI.
下面的页面讨论了当前MonoVS调试器实现的一些问题,但它们对我来说都很好.
http://mono-project.com/Visual_Studio_Integration
该页面还链接到MonoVS的入门指南:
http://mono-project.com/GettingStartedWithMonoVS
其中包含MonoTools的下载链接:
http://mono-tools.com/download/
但是,下载链接现在重定向到:
在哪里我可以下载Xamarin Studio Starter Edition.单击"定价"链接,我发现至少需要Visual Studio支持的商业版,每年999美元.好吧,不,谢谢.
这就是我被困住的地方.我的环境的一些细节:
开发环境:
目标环境:
以下是DNX的说明:
.NET执行环境(DNX)是一个软件开发工具包(SDK)和运行时环境,具有构建和运行Windows,Mac和Linux的.NET应用程序所需的一切.它提供主机进程,CLR托管逻辑和托管入口点发现.DNX是为运行跨平台的ASP.NET Web应用程序而构建的,但它也可以运行其他类型的.NET应用程序,例如跨平台控制台应用程序.
DNX是单声道的替代品吗?如果没有,那会有什么区别?
我在ServiceStack Web应用程序中使用WebRequest有一个非常奇怪的问题(由Mono上的XSP托管).似乎请求模块的注册以一种非常奇怪的方式工作; 我正在使用WebRequest创建HTTP请求,但它失败了,因为它无法找到该"前缀"(HTTP)的创建者.
我看到的例外情况是NotSupportedException,我能够跟踪它没有为HTTP前缀注册创建者这一事实(我正在点击https://github.com/mono/mono/blob/master/mcs/class/ System/System.Net/WebRequest.cs,第479行)
编辑:更多细节:NotSupportedException抛出WebRequest.GetCreator,它使用URL前缀作为键来选择要返回的创建者; 在我的情况下,一个HttpRequestCreator.抛出异常是因为没有为"HTTP"前缀注册的创建者(实际上,根本没有创建者).
所以我搜索了一下,挖掘了Mono源代码,发现模块是(或应该)添加到system.web的webRequestModules部分的各种*.config文件中.
我查看了我的machine.config文件,它是:
System.Net.HttpRequestCreator, System, Version=4.0.0.0
看看WebRequest Mono的来源 ,似乎前缀是从配置确实添加的,在类静态构造函数内(不是一个好的选择,恕我直言,但仍然......应该工作).
为了测试它,我尝试了添加HttpRequestCreator到system.net/webRequestModules我的web.config; 这是由XSP/Mono加载并导致重复的键异常(这是预期的,因为HttpRequestCreator应该已经加载,因为它已经存在于machine.config中).
更奇怪的是:如果我为Http添加一个模拟处理程序,就像这样:
bool res = System.Net.WebRequest.RegisterPrefix ("http", new MyHttpRequestCreator ());
Debug.Assert (res == false);
Run Code Online (Sandbox Code Playgroud)
断言有时会通过......有时候不会!(如果已经注册了相同前缀的创建者,则RegisterPrefix返回"false";我希望它总是返回false,但事实并非如此!再次,它是完全随机的)
当注册"失败"(即因为已经注册了"HTTP"前缀而返回false)时,WebRequest可以创建HTTP请求.就像调用RegisterPrefix"唤醒"静态构造函数并让它运行一样.
我很困惑:它似乎是执行WebRequest的静态构造函数时的竞争条件,但这没有意义(运行时保护带有锁的静态构造函数,IIRC)
我错过了什么?我该如何解决或解决这个问题?这是我的错(误解或遗漏某些东西)还是看起来像是一个Mono bug,因此我应该提交它吗?
细节:
mono --version Mono JIT编译器版本3.0.6(Debian 3.0.6 + dfsg-1~exp1~pre1)
(可能相关的,未回答的问题:单声道下WebRequest不支持HTTP协议)
mono ×10
c# ×5
.net ×3
c++-cli ×1
dnx ×1
gmail ×1
gmcs ×1
ildasm ×1
moma ×1
monodevelop ×1
openxml-sdk ×1
raspberry-pi ×1
raspbian ×1
servicestack ×1
smtpclient ×1
uibutton ×1
uikit ×1
xamarin.ios ×1
xsp ×1