我有一个我开发的ASP.Net MVC 3应用程序,它使用RavenDB Embedded作为数据的集成后备存储,我使用本教程作为开始使用RavenDB Embedded创建MVC应用程序的基础.我已经能够在我的开发PC上运行得很好,但是当它在我们运行IIS6的Windows Server 2003 Web服务器上部署时,它会抛出以下错误:
无法访问文件,文件已锁定或正在使用说明:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息.
异常详细信息:Microsoft.Isam.Esent.Interop.EsentFileAccessDeniedException:无法访问文件,文件被锁定或正在使用中
来源错误:
在执行当前Web请求期间生成了未处理的异常.可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息.
堆栈跟踪:
[EsentFileAccessDeniedException:无法访问文件,文件被锁定或正在使用] C:\ Work\ravendb\SharedLibs\Sources\managedesent-61618\EsentInterop\Api中的Microsoft.Isam.Esent.Interop.Api.Check(Int32错误). cs:2736 Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator)在c:\ Builds\RavenDB-Stable\Raven.Storage.Esent\TransactionalStorage.cs:207
[InvalidOperationException:无法
在c:\ Builds\RavenDB-Stable\Raven中打开事务存储:C:\ inetpub\wwwroot\MyApp\App_Data\Database\RavenDB\Data] Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator) .Storage.Esent\TransactionalStorage.cs:222 Raven.Database.DocumentDatabase..ctor(InMemoryRavenConfiguration配置)在c:\ Builds\RavenDB-Stable\Raven.Database\DocumentDatabase.cs:185
Raven.Client.Embedded.EmbeddableDocumentStore.InitializeInternal ()在c:\ Builds\RavenDB-Stable\Raven.Client.Embedded\EmbeddableDocumentStore.cs:143中的Raven.Client.Document.DocumentStore.Initialize()在c:\ Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\DocumentStore.cs:496 MyApp.CompositionRoot.CreateControllerFactory()in ...\MyApp\CompositionRoot.cs:36 MyApp.CompositionRoot..ctor()in ..\MyApp\CompositionRoot.cs:17
MyApp.MvcApplication.Application_Start ()in ... MyApp\Global.asax.cs:38[HttpException(0x80004005):无法打开事务存储:C:\ inetpub\wwwroot\MyApp\App_Data\Database\RavenDB\Data]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context,HttpApplication app)+3985477
System.Web.HttpApplication .RegisterEventSubscriptionsWithIIS(IntPtr appContext,HttpContext context,MethodInfo [] handlers)+191
System.Web.HttpApplication.InitSpecial(HttpApplicationState state,MethodInfo [] handlers,IntPtr appContext,HttpContext context)+325
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext ,HttpContext context)+407
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)+375[HttpException(0x80004005):无法打开事务存储:C:\ inetpub\wwwroot\MyApp\App_Data\Database\RavenDB\Data]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context)+11524352 System.Web.HttpRuntime.EnsureFirstRequestInit( HttpContext context)+141 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext context)+4782309
引用的CompositionRoot.cs类中的错误源是Embeddable Document Store的初始化时.
private …Run Code Online (Sandbox Code Playgroud) 我是否误解了使用任何一个CRC32或多个CheckedInputStream类来通过不断更新最新输入来计算校验和?当输入<= 128KiB时,生成有效的CRC32.任何大于128KiB且校验和失败的东西.下面是我正在使用的一些代码(使用CRC32对象,BufferedInputStream但如果我使用a CheckedInputStream来跟踪CRC32,则会出现同样的问题).
我将不胜感激任何建议或意见,谢谢
private static long calcCRC32() throws IOException {
BufferedInputStream inStream = new BufferedInputStream(System.in);
int BLOCK_SIZE = 128*1024; //128KiB
int len;
byte[] buffer = new byte[BLOCK_SIZE];
CRC32 crc32 = new CRC32();
crc32.reset();
while((len = bufferedInputStream.read(buffer, 0, BLOCK_SIZE)) > 0){
crc32.update(buffer, 0, len);
buffer = new byte[BLOCK_SIZE];
}
return crc32.getValue();
}
Run Code Online (Sandbox Code Playgroud) 我使用Selenium和C#进行自动化,我想通过代码调用NUnit,如下所示:
CoreExtensions.Host.InitializeService();
TestPackage testPackage = new TestPackage(@"D:\Automation\bin\Debug\Test.dll");
RemoteTestRunner remoteTestRunner = new RemoteTestRunner();
remoteTestRunner.Load(testPackage);
//TestFilter filter = new NameFilter(new TestName() { Name = "Test1" });
TestResult testResult = remoteTestRunner.Run(
new NullListener(),
TestFilter.Empty,
false,
LoggingThreshold.Off
);
Run Code Online (Sandbox Code Playgroud)
我可以使用类别过滤器运行测试,如下所示
remoteTestRunner.Run(
new NullListener(),
new CategoryFilter("MyCat"),
false,
LoggingThreshold.Off
);
Run Code Online (Sandbox Code Playgroud)
但我想执行特定的测试.如何设置套件过滤器?我尝试了以下,但它不起作用:
TestFilter filter = new NameFilter(new TestName() { Name = "Test1" });
TestResult testResult = remoteTestRunner.Run(
new NullListener(),
filter,
false,
LoggingThreshold.Off
);
Run Code Online (Sandbox Code Playgroud)
如何运行特定测试以及如何通过代码传递参数?
我想用一个指定的参数包装一个函数,比如functools.partial,但是它没有按预期工作:
source_codes = (0, 1, 2)
def callback(source, *args):
print 'callback from source: ', source
funcs = []
for source in source_codes:
funcs.append(lambda *args: callback(source, *args))
for i, func in enumerate(funcs):
print 'source expected: ', i
func()
print
Run Code Online (Sandbox Code Playgroud)
输出:
source expected: 0
callback from source: 2
source expected: 1
callback from source: 2
source expected: 2
callback from source: 2
Run Code Online (Sandbox Code Playgroud)
但是......我想要的是:
source expected: 0
callback from source: 0
source expected: 1
callback from source: 1
source expected: 2 …Run Code Online (Sandbox Code Playgroud) 对于这个基本数据帧,我想将行设置为等于其他行.我一次做这一行没有问题:
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randn(10, 5))
df.loc[6,:] = df.loc[4,:]
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试为多行执行此操作时,它们被设置为NaN而不是我引用的行:
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randn(10, 5))
df.loc[5:6,:] = df.loc[3:4,:]
Run Code Online (Sandbox Code Playgroud)
我已阅读文档,无法找到解释.有任何想法吗?谢谢.
我有一个未被调用的函数。我尝试使用调试来编写文件,它正确地写入了第一条调试消息"debug0"。但不是其他消息。
这是aspx:
<%@PageLanguage="C#"AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>
<!DOCTYPE html PUBLIC >
<html>
<head runat="server">
<title/>
<link rel="stylesheet" type="text/css" href=".//style.css" />
</head>
<body>
<form class="container" runat="server">
<asp:login id="Login1" runat="server" style="width: 100%;">
<LayoutTemplate>
<div id="content">
<h1>blah<br>Site Login </h1>
<asp:TextBox class="field" placeholder="Username" ID="username" runat="server"> </asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="Login1">*
</asp:RequiredFieldValidator>
<br>
<asp:TextBox class="field" placeholder="Password" ID="password" runat="server" TextMode="Password"/>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="Login1">*
</asp:RequiredFieldValidator>
<br>
<asp:Button class="btn" ID="LoginButton" …Run Code Online (Sandbox Code Playgroud) 我正在维护一些现有的页面,并且遇到了一些代码System.Threading,我不知道该怎么做.
(这是它的要点)
protected void Page_Load(object sender, EventArgs e)
{
XmlDocument xmlDoc = GetFromCMS();
var nodes = xmlDoc.SelectNodes("/xpath/to/nodes");
int i = 0;
while (i < nodes.Count)
{
//do stuff with nodes[i]
//last line in while loop - this is where I'm confused
Math.Max(System.Threading.Interlocked.Increment(ref i), i - 1);
}
}
Run Code Online (Sandbox Code Playgroud)
做这样的事情有意义吗?不能i增加ala i++而不是?我不熟悉多线程,但鉴于此页面上没有其他线程代码,并且没有真正"特殊"发生(没有创建额外的线程等),对我来说似乎有点奇怪.
谢谢你的协助!
朋友们!
所以我一直在写一个简单的程序.基本上,我有一个类(3个字符串,1个int,一些方法).我正在从文本文件初始化此类的对象的值.我正在使用List.问题是初始化是一个单独的功能.我在这个函数中声明并初始化了List BOTH.但是,我可能在其他功能中需要它,包括"Program.Main".
我应该制作一个"全球"课程并制作一个公开的List <Class>吗?我决定立即在我的Program.Main函数中声明它.但是,我不确定,List是通过值还是通过引用传递的.我在网上找到了一个页面,建议使用ref关键字.我现在有:
public Class FooClass
{...}
class Program
{
static void Main(string[] args)
{
List<FooClass> fooDB = new List<FooClass>;
initFromFile(ref fooDB);
}
private static initFromFile(ref List<FooClass> fooDB)
{
using (StreamReader ... )
{
while( ... )
{
...
fooDB.Add(new FooClass(args))
}
}
}//initFromFile
}//Program
Run Code Online (Sandbox Code Playgroud)
我应该继续像这样工作吗?还是有任何重要的建议?也许"参考"根本不是一个好习惯?
TLDR:我应该制作一个全局列表还是将其作为参考或其他方式传递(建议).如果通过引用传递,那么我应该使用ref关键字还是有另一种方式?
提前致谢,
~~~ hlfrmn