Tag: .net

可以直接从C#使用Profiling API吗?

我只想使用.NET Profiling API( ICorProfilerCallback等),但同时又不想处理C ++。 我一直在寻找一段时间,但没有在C#中找到任何例子,而是C#+ C ++,其中最有趣的部分是使用C ++编写的。

如何将图像URL转换为system.drawing.image

我正在使用VB.Net我有一个图像的url,让我们说http://localhost/image.gif 我需要从该文件创建一个System.Drawing.Image对象。 请注意将此保存到文件然后打开它不是我的选项之一,我也在使用ItextSharp 这是我的代码: Dim rect As iTextSharp.text.Rectangle rect = iTextSharp.text.PageSize.LETTER Dim x As PDFDocument = New PDFDocument(“chart”, rect, 1, 1, 1, 1) x.UserName = objCurrentUser.FullName x.WritePageHeader(1) For i = 0 To chartObj.Count – 1 Dim chartLink as string = “http://localhost/image.gif” x.writechart( ** it only accept system.darwing.image ** ) Next x.WritePageFooter() x.Finish(False)

使用LINQ的IQueryable左外连接的扩展方法

我试图实现返回类型为IQueryable Left outer join扩展方法。 我写的function如下 public static IQueryable LeftOuterJoin2( this IQueryable outer, IQueryable inner, Func outerKeySelector, Func innerKeySelector, Func resultSelector) { return from outerItem in outer join innerItem in inner on outerKeySelector(outerItem) equals innerKeySelector(innerItem) into joinedData from r in joinedData.DefaultIfEmpty() select resultSelector(outerItem, r); } 它无法生成查询。 原因可能是:我使用了Func而不是Expression 。 我也试过Expression 。 它在outerKeySelector(outerItem)行上给出了一个错误,即outerKeySelector是一个用作方法的变量 我发现了一些关于SO(例如这里 )和CodeProjects的讨论,但是那些适用于IEnumerable类型的讨论不适用于IQueryable 。

如何从C#代码进入SQL Server存储过程?

我正在调试一些使用Ado.net在SQL Server中调用存储过程(TSQL)的C#代码。 我怎样才能进入存储过程? (我想我已经看到这个由微软工作人员演示,但是不能回想起让它工作所需的101个“神奇”设置。)

拦截IDisposable.Dispose中的exception

在IDisposable.Dispose方法中有一种方法可以判断是否抛出exception? using (MyWrapper wrapper = new MyWrapper()) { throw new Exception(“Bad error.”); } 如果在using语句中抛出exception,我想在处理IDisposable对象时知道它。

使用WPF数据网格时如何更改列标题的背景颜色

使用WPF数据网格时如何更改列标题的背景颜色? 需要直接修改xaml吗?

自动滚动文本框使用的内存比预期的多

我有一个应用程序使用TextBox将消息记录到屏幕上。 更新function使用一些Win32函数来确保框自动滚动到结尾,除非用户正在查看另一行。 这是更新function: private bool logToScreen = true; // Constants for extern calls to various scrollbar functions private const int SB_HORZ = 0x0; private const int SB_VERT = 0x1; private const int WM_HSCROLL = 0x114; private const int WM_VSCROLL = 0x115; private const int SB_THUMBPOSITION = 4; private const int SB_BOTTOM = 7; private const […]

Linq 中的lambda /方法语法中的左外连接

可能重复: 如何使用linq扩展方法执行左外连接 我找不到Linq lambda的左外连接示例(使用扩展方法),至少不是一个明确的。 假设我有下表: Parent { PID // PK } Child { CID // PK PID // FK Text } 我想加入Parent with Child,对于每个失踪的孩子,我希望Text的默认值为“[[Empty]]”。 我怎么能用linq lambda语法做到这一点? 我目前有以下内容: var source = lParent.GroupJoin( lChild, p => p.PID, c => c.PID, (p, g) => new // ParentChildJoined { PID = p.PID; // How do I add child values […]

IEnumerable VS IList VS IQueryable

MVC.net场景的新手(以及.net),但是当我想要用数据填充“列表”时,我似乎找到了各种各样的选项。 在我的情况下,我想从一个选择的项目查询填充一个列表,并用JSON渲染结果输出,所以请耐心等待…. 所以,我的viewmodel类是这样的: [Serializable()] public class TFSquery { public int MsgUid { get; set; } public DateTime CreateStamp { get; set; } } 然后我想用我的查询输出填充它: List z = (from msg in _DB.Msg select new { msg.MsgUID, msg.CreateStamp }).ToList(); 那么我会将输出循环到我的List中,以便我可以在我的Json返回字符串中输出吗? 当我使用LIST VS IENUMERABLE VS IQUERYABLE ? return Json(new { Result = z }, JsonRequestBehavior.AllowGet);

将List 添加到mysql参数

我有关于.NET连接器的MySqlParameter的这个问题。 我有这个问题: SELECT * FROM table WHERE id IN (@parameter) 而MySqlParameter是: intArray = new List(){1,2,3,4}; …connection.Command.Parameters.AddWithValue(“parameter”, intArray); 这个有可能? 是否可以将int数组传递给单个MySqlParameter? 另一个解决方案是将int数组转换为像“1,2,3,4”这样的字符串,但是当我将它传递给MySqlParameter并将其识别为字符串时,它会像sql查询一样放入“1 \,2 \,3 \,4”,这不会返回预期值。 @ UPDATE:似乎mysql连接器团队应该更加努力。