Visual Studio习惯在我的解决方案中打开错误的文件 - 只有一小部分时间,但一天几次,往往足以令人讨厌.执行以下任何操作时都可能发生这种情况:
有没有其他人经历过这一点,并有任何想法可以导致/解决这个问题?
更新:我终于安装了SP1,它仍然会发生,所以我回来寻找解决方案.
如果它是相关的,我已经安装了Resharper 5.1和Visual Studio Productivity Power Tools.
更新2:看起来Visual Studio Productivity Power Tools是问题的一部分,我已经卸载它并且从那时起就没有问题.
我正在使用Facebook发送对话框向朋友发送消息.正如此处所述:https://developers.facebook.com/docs/reference/dialogs/send/并且正在使用类似于Facebook示例中的链接:
https://www.facebook.com/dialog/send?app_id=123050457758183&name=People%20Argue%20Just%20to%20Win&link=http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html&redirect_uri=http://www.example.com/response
在我指定的页面上,redirect_uri我正在显示文字说:"您的邮件已被发送".但是,即使你在Facebook对话框中点击了取消,我也意识到你会看到这个页面.
有没有办法确定是否点击了保存或取消?
更新:我找到了一个使用FB.ui方法的解决方法,它解决了我遇到的直接问题. 我仍然有兴趣知道是否有人使用如上所述的发送对话链接有更好的解决方案.
我有以下代码:
using (var doc = WordprocessingDocument.Open(filename, true))
{
....
}
Run Code Online (Sandbox Code Playgroud)
其中string filename是docx文件的有效路径.
但是调用Open会导致以下InvalidOperationException: Specified part does not exist in the package.
编辑:我认为问题是由于我试图打开的docx文件无效,所以我将发布xml:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 wp14">
<w:body xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:p w:rsidRPr="005501CD" w:rsidR="00217D87" w:rsidP="005501CD" w:rsidRDefault="005501CD">
<w:r>
<w:t xml:space="preserve">Hello </w:t>
</w:r>
<w:r>
<w:rPr>
<w:noProof />
</w:rPr>
<w:t>John</w:t>
</w:r>
<w:r>
<w:t xml:space="preserve"> </w:t>
</w:r>
<w:r>
<w:rPr>
<w:noProof />
</w:rPr>
<w:t>Smith</w:t>
</w:r>
<w:r>
<w:t>,</w:t>
</w:r>
<w:bookmarkStart …Run Code Online (Sandbox Code Playgroud) 我有三个用户控件:usercontrolA,usercontrolB以及usercontrolC其所有共享相同的代码隐藏每个都具有:
<%@ Control Language="c#" AutoEventWireup="True" Codebehind="usercontrolA.ascx.cs" Inherits="usercontrolA" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %> 在ascx的顶部.
在codebehind文件中,我有一个名为的公共属性ShowAll.
我知道我可以在将usercontrol放在页面上时设置此属性,例如
<uc1:usercontrolB ID="usercontrolB1" runat="server" ShowAll="true" />
但是我希望ShowAll始终在usercontrolB上设置为true,所以不必每次将它放在页面上时都要设置它.
我知道我可以在usercontrolB中添加一个脚本标签来设置ShowAll Page_Load:
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e)
{
ShowAll = true;
}
</script>
Run Code Online (Sandbox Code Playgroud)
但是想要保留Page_Load我已经在代码隐藏中实现的实现. 有没有其他方法为usercontrolB自动设置此属性?
编辑:如果有可能我希望能够在ascx而不是后面的代码中设置它,以便后来的其他人可以为所有实例添加usercontrolD并设置ShowAll为true,usercontrolD而无需让我修改和重新编译代码隐藏.
我一直在使用自定义格式显示DateTimes,如下所示:http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
例如
new DateTime(2011,10,5).ToString("dd");
Run Code Online (Sandbox Code Playgroud)
返回: "05"
和:
new DateTime(2011,10,5).ToString("d MM");
Run Code Online (Sandbox Code Playgroud)
返回 "5 10"
这两者都是我所期望的,但是:
new DateTime(2011,10,5).ToString("d");
Run Code Online (Sandbox Code Playgroud)
返回: "05/10/2011"
当我希望它返回时: "5"
这在实践中并不重要,因为你会使用:new DateTime(2011,10,5).Day获得一天,但我感兴趣的是为什么自定义格式不能像我预期的那样工作.
我有一个'Setup'视图和相关的控制器,我用它来源从源代码控制中克隆网站后立即配置MVC站点的数据库和web.config.
一旦运行一次,我想阻止我的'Setup'控制器方法中的代码再次运行.
在我的'Setup'控制器方法结束时以编程方式删除'Setup'视图就足够了,还是有更好的方法?