小编Cor*_*lin的帖子

构建机器上的大型TFSUser\AppData\Local\Temp目录

我在Windows Server 2008 R2上使用TFS 2012 Update 1.我们在TFSUser帐户下运行TFS构建.有一天,我们的构建机器上的空间不足.经过调查,我发现文件夹C:\ Users\TFSUser\AppData\Local\Temp中有超过50GB的文件,有些可以追溯到2012年10月.没有一个文件过大,但它们没有似乎得到了清理.

今天调查显示,在自动构建期间,文件夹会被写入很多内容.为什么这些文件没有得到清理,我该怎么做才能确保我的构建机器不会因为这个问题而再次耗尽空间?

更新2013-03-13
我创建了一个小型PowerShell脚本,每晚运行以删除临时目录内容.这是powershell脚本:

Stop-Service TFSBuildServiceHost.2012
Remove-Item Drive:\Path\To\TFSUser\AppData\Local\Temp\* -recurse -exclude Build*
Start-Service TFSBuildServiceHost.2012
Run Code Online (Sandbox Code Playgroud)

我的任务是每晚以提升的权限运行作为TFSUser帐户.需要提升权限,因为我们需要启动和停止服务.

tfs tfsbuild visual-studio tfs2012

12
推荐指数
1
解决办法
7771
查看次数

Ruby:Declarative_authorization多态关联

我有两个模型(项目和主题).它们都归第三个模型所有,具有has_many关联的用户(用户拥有许多主题和项目).项目和主题都具有多种:图像.

Image模型是一个多态关联,因此该表的列为imageable_id和imageable_type.如果我同时拥有ID为1的Item和ID为1的Theme,则该表将如下所示

id    imageable_id    imageable_type
------------------------------------
1     1               Item
2     1               Theme
Run Code Online (Sandbox Code Playgroud)

我正在使用declarative_authorization来重写我的数据库的SQL查询,以防止用户访问其帐户之外的项目.我想编写一个授权规则,允许用户只有在他们可以阅读他们拥有的项目时才能阅读图像.我似乎无法获得正确的语法(也许它不受支持):

has_permission_on [:images], :to => [:manage], :join_as => :and do
  if_attribute :imageable => is { "Item" }
  if_permitted_to :manage, :items # Somehow I need to tell declarative_auth to imageable_id is an item_id in this case.
end
Run Code Online (Sandbox Code Playgroud)

然后我会有另一个模仿上述但主题的规则:

has_permission_on [:images], :to => [:manage], :join_as => :and do
  if_attribute :imageable => is { "Theme" }
  if_permitted_to :manage, :themes # Somehow I need to tell declarative_auth to imageable_id is a theme_id …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails polymorphic-associations declarative-authorization

7
推荐指数
1
解决办法
423
查看次数

ASP.NET DllImport导致应用程序退出

我怀疑我的问题是由于一些安全问题,但这里是完整的描述,以防万一我弄错了.

我有一个最初用C(不是C++)编写的DLL.我正在使用DllImport来调用此库中的方法.声明看起来像这样:

[DllImport(@"MyAntiquatedLibrary.dll")
[SecurityPermission(SecurityAction.Assert, Unrestricted = true)]
internal static extern void GetConnectionString(string port, string server, string instance, [Out] StringBuilder output);
Run Code Online (Sandbox Code Playgroud)

头文件中的C声明如下所示:

void GetConnectionString(const char far *Portname, const char far *ServerName const char far *InstanceName, char far *retConnectionName);
Run Code Online (Sandbox Code Playgroud)

所以我在visual studio的WebApplication项目中创建了一个示例页面,其代码隐藏如下:

protected void Page_Load(object sender, EventArgs e)
{
  try
  {
    var connectionString = new StringBuilder();
    GetConnectionString(null, "myHost", "myInstance", connectionString);
    MyLabel.Text = connectionString.ToString();
  }
  catch(Exception ex)
  {
    MyLabel.Text = string.Format("Something went wrong: {0}", ex.Message);
  }
}
Run Code Online (Sandbox Code Playgroud)

当我调试程序并跳过GetConnectionString()方法调用时,我得到一个:

AccessViolationException was unhandled.
Attempted to read …
Run Code Online (Sandbox Code Playgroud)

c# asp.net interop dllimport

5
推荐指数
1
解决办法
819
查看次数