我创建了一个调试监听器,使用以下代码将Debug/Console窗口的输出重定向到一个文件(带有一个调用堆栈):
void SomeMethod()
{
// Create a file for output .txt.
Stream debugFile = File.Create(fileName);
// create TextWriterTraceListener named "file"
TextWriterTraceListener debugWriter = new TextWriterTraceListener(debugFile, "file");
// add to debug listeners
Debug.Listeners.Add(debugWriter);
// set callstack to be shown
Debug.Listeners["file"].TraceOutputOptions |= TraceOptions.Callstack;
// set auto-flush
Debug.AutoFlush = true;
}
Run Code Online (Sandbox Code Playgroud)
但输出不会重定向到我指定的文件,它总是为空.
我从我的主窗体中的构造函数中调用它.我是从问题中调用它的地方吗?
我在这里尝试实现的是将调试输出窗口中的异常放在带有调用堆栈的文件中,以便我可以找到它们并更正它们.
更新:经过一些研究后,我得出结论,TraceListener
在Debug Listeners
集合中添加一个新的不会重定向调试/控制台的输出.它实际上只是回应Write
,WriteLine
等方法一样默认的监听器.问题仍然存在:如何捕获Debug/Console窗口的输出以及如何获取出现在那里的异常的堆栈跟踪?
有人有主意吗?
我必须完全禁用 Windows 窗体和其中包含的每个控件上的鼠标滚轮,我已经尝试使用事件鼠标滚轮,但它无法正常工作:
this.MouseWheel += new MouseEventHandler(Form_MouseWheel);
private void Form_MouseWheel(object sender, MouseEventArgs e) {
((HandledMouseEventArgs)e).Handled = true;
}
Run Code Online (Sandbox Code Playgroud)
如何在 Windows 窗体及其内部的每个控件中完全禁用鼠标滚轮?
"活动"是一个有点领域.如果其中一个具有此client_id的行的值为true,则需要将其设置为true
SELECT c.client_id, u.branch_id, a.account_id, activity
FROM Clients c INNER JOIN
accounts a ON c.id=a.client_id INNER JOIN uso u ON a.uso_id = u.uso_id,
(SELECT MAX(CONVERT(int,accounts.activity)) as activity, client_id
FROM accounts GROUP BY client_id) activ
WHERE activ.client_id = c.id
Run Code Online (Sandbox Code Playgroud)
此查询执行大约2分钟.请帮我优化一下.
我在我的一个存储过程中使用全文搜索.在此之前(典型示例将是几分钟)我将项目插入到具有全文索引和表中约350万行的表中.当我试图在上面提到的存储过程中找到它时,该项目不存在(或搜索查询找不到它).所以我猜测索引在那时仍未更新.
问题是......甚至可能是这种情况还是我的问题出在其他地方?
如果是的话......全文索引何时更新?处理索引的时间是否取决于它拥有的数据量?大约400万条记录通常需要多长时间?
我正在使用SQL Server 2008.
使用Sql Server 2008,如何使用全文搜索实际找到精确的字符串匹配.我真的很难过,而且我无法在网上找到满意的解决方案.
例如,如果我正在搜索字符串"Bojan Skrchevski",我希望第一个结果就是这样.
到目前为止,我已经尝试将字符串格式化为:"Bojan*NEAR Skrchevski*"并调用CONTAINSTABLE来获取结果,但是这个字符串被格式化为返回更多结果,如Bojana和Bojananana等.我也尝试了ORDER BY RANK,但仍然没有成功.
此外,在我的字符串中我有一个数字序列,如:"3 1 7",但使用当前格式,它也返回"7 1 3"等.
例:
DECLARE @var varchar(4000);
SET @var = '"Oxford*" NEAR 24 NEAR 7 NEAR 5 NEAR "London*"'
SELECT [Key] FROM CONTAINSTABLE(dbo.[MyTable], [MyField], @var);
Run Code Online (Sandbox Code Playgroud)
我希望能够得到确切的订单.结果不要"牛津7 24 5伦敦".
如何格式化字符串以正确完成此操作?
我有文件夹C:\ Temp \,它有两个文件des.exe和input.abcd.des.exe用于解密input.abcd.在命令提示符下面的2行内容
cd C:\Temp\
des.exe XXXX input.abcd output.zip
Run Code Online (Sandbox Code Playgroud)
以下为什么不起作用#
string argument1 = "/K cd C:\\Temp\\ ";
string argument2 = "des.exe XXXX input.abcd output.zip" ;
System.Diagnostics.ProcessStartInfo proc = new System.Diagnostics.ProcessStartInfo();
proc.FileName = @"C:\windows\system32\cmd.exe";
proc.Arguments = String.Format("{0} {1}", argument1, argument2);
proc.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
System.Diagnostics.Process.Start(proc);
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用C#和JSON.Net在网站上加载JSON文件
但是,我在运行时遇到问题,因为所有JSON都在[]内.
这是JSON:
[{"embed_count":"16","name":"live_user_catreina","stream_count":"133","category":"gaming","format":"live","channel_count":272,"title":"SWTOR - Sith Marauder - L42 - Belsavis - The Fatman","featured":true,"site_count":"117","abuse_reported":false,"channel":{"image_url_large":"http://static-cdn.jtvnw.net/jtv_user_pictures/catreina-profile_image-2c63d1c5b60987da-300x300.jpeg","channel_url":"http://www.justin.tv/catreina","category_title":"Gaming","screen_cap_url_large":"http://static-cdn.jtvnw.net/previews/live_user_catreina-320x240.jpg","mature":null,"subcategory":null,"category":"gaming","image_url_medium":"http://static-cdn.jtvnw.net/jtv_user_pictures/catreina-profile_image-2c63d1c5b60987da-150x150.jpeg","subcategory_title":null,"status":"SWTOR - Sith Marauder - L42 - Belsavis - The Fatman","screen_cap_url_medium":"http://static-cdn.jtvnw.net/previews/live_user_catreina-150x113.jpg","image_url_small":"http://static-cdn.jtvnw.net/jtv_user_pictures/catreina-profile_image-2c63d1c5b60987da-70x70.jpeg","timezone":"US/Eastern","screen_cap_url_small":"http://static-cdn.jtvnw.net/previews/live_user_catreina-70x53.jpg","id":5895485,"views_count":"6142420","embed_enabled":true,"embed_code":" <object type=\"application/x-shockwave-flash\" height=\"295\" width=\"353\" id=\"live_embed_player_flash\" data=\"http://www.justin.tv/widgets/live_embed_player.swf?channel=catreina\" bgcolor=\"#000000\"><param name=\"allowFullScreen\" value=\"true\" /><param name=\"allowscriptaccess\" value=\"always\" /><param name=\"movie\" value=\"http://www.justin.tv/widgets/live_embed_player.swf\" /><param name=\"flashvars\" value=\"start_volume=25&channel=catreina&auto_play=false\" /></object>\n","producer":true,"image_url_tiny":"http://static-cdn.jtvnw.net/jtv_user_pictures/catreina-profile_image-2c63d1c5b60987da-50x50.jpeg","image_url_huge":"http://static-cdn.jtvnw.net/jtv_user_pictures/catreina-profile_image-2c63d1c5b60987da-600x600.jpeg","language":"en","tags":"games gaming lord lotro mmo mmorpg of online pc rings rpg sc2 scii starcraft starcraft2 the vindictus warcraft wow","login":"catreina","screen_cap_url_huge":"http://static-cdn.jtvnw.net/previews/live_user_catreina-630x473.jpg","title":"Gaming With Catreina"},"video_height":720,"language":"en","video_bitrate":1987.1328125,"id":"2309110144","meta_game":"Star Wars: The Old Republic","broadcaster":"fme","broadcast_part":4,"audio_codec":"uncompressed","up_time":"Mon Dec 26 00:06:03 2011","video_width":1280,"geo":"US","channel_view_count":6133751,"channel_subscription":false,"embed_enabled":true,"stream_type":"live","video_codec":"AVC"}]
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下代码加载它:
class Program
{
static void Main(string[] args)
{ …
Run Code Online (Sandbox Code Playgroud) 如何在Collection继承类中找到元素的索引?
public class MyCollection : Collection<MyClass>
{
// implementation here
}
Run Code Online (Sandbox Code Playgroud)
我试图在集合上使用.FindIndex但没有成功:
int index = collectionInstance.FindIndex(someLambdaExpression);
Run Code Online (Sandbox Code Playgroud)
还有其他方法可以实现吗?
我想创建一个具有子属性的属性的类...
换句话说,如果我做了类似的事情:
Fruit apple = new Fruit();
Run Code Online (Sandbox Code Playgroud)
我想要这样的东西:
apple.eat(); //eats apple
MessageBox.Show(apple.color); //message box showing "red"
MessageBox.Show(apple.physicalProperties.height.ToString()); // message box saying 3
Run Code Online (Sandbox Code Playgroud)
我认为它会这样做:
class Fruit{
public void eat(){
MessageBox.Show("Fruit eaten");
}
public string color = "red";
public class physicalProperties{
public int height = 3;
}
}
Run Code Online (Sandbox Code Playgroud)
......但是,如果那行得通,我就不会在这里......
使用delphi 2010,我想知道是否有某种方法来逃避以下字符串,以使其免受sql注入攻击:
我的字符串:
SQLQuery1.SQL.Text := 'SELECT * FROM registered WHERE email="'+
email+'" and login_pass="'+password+'"';
Run Code Online (Sandbox Code Playgroud)
如何重写这个字符串,使其比有人在我的TEditbox中输入"他的电子邮件或密码"更安全!
c# ×6
sql ×4
.net ×1
brackets ×1
class ×1
debugging ×1
delphi ×1
delphi-2010 ×1
events ×1
inheritance ×1
json ×1
json.net ×1
jsonreader ×1
mouseevent ×1
nested ×1
redirect ×1
sql-server ×1
t-sql ×1