我有一个使用 MySql 数据库的 ac# 应用程序,问题是在一段时间不活动(8 小时)后或与数据库所在的服务器的连接丢失时,与数据库的连接关闭,无法执行数据库查询。如何启用自动重新连接到数据库。
此致。
我正在使用webBrowser控件在winforms中打开PDF文档,它工作正常但是在关闭应用程序时我偶尔会遇到错误:"0x2d864aa2处的指令"引用"0x00000008"处的内存.内存无法"读取".有这个问题的解决方案吗?
问候.
我正在使用互操作,我想得到word文档中包含的所有内容控件的列表(在正文,形状,页眉,页脚..).这是正确的,也是最好的方法:
public static List<ContentControl> GetAllContentControls(Document wordDocument)
{
if (null == wordDocument)
throw new ArgumentNullException("wordDocument");
List<ContentControl> ccList = new List<ContentControl>(); ;
// Body cc
var inBodyCc = (from r in wordDocument.ContentControls.Cast<ContentControl>()
select r);
ccList.AddRange(inBodyCc);
// cc within shapes
foreach (Shape shape in wordDocument.Shapes)
{
if (shape.Type == Microsoft.Office.Core.MsoShapeType.msoTextBox)
{
ccList.AddRange(WordDocumentHelper.GetContentControlsInRange(shape.TextFrame.TextRange));
}
}
// Get the list of cc in the story ranges : wdFirstPageHeaderStory, wdFirstPageFooterStory, wdTextFrameStory (textbox)...
foreach (Range range in wordDocument.StoryRanges)
{
ccList.AddRange(WordDocumentHelper.GetContentControlsInRange(range));
}
return ccList;
}
public static List<ContentControl> …Run Code Online (Sandbox Code Playgroud)