我有一个使用ASP.NET MVC3和Ninject.Web.MVC(MVC3版本)的简单Web应用程序.
整个过程正常,除非应用程序结束.每当它结束时,就会释放内核,如NinjectHttpApplication中的Application_End()所示:
反射器告诉我这个:
public void Application_End()
{
lock (this)
{
if (kernel != null)
{
kernel.Dispose();
kernel = null;
}
this.OnApplicationStopped();
}
}
Run Code Online (Sandbox Code Playgroud)
发生的事情是我的网络服务器出现了StackOverflowException(我在VS2010中尝试了IIS7和内置的web服务器).我只能假设这是出错的地方,因为我自己没有在应用程序端编写任何代码.
我发现内核知道如何解析IKernel(它返回内核本身),这可能会导致堆栈溢出吗?我可以想象会发生这样的事情:
换句话说,内核被释放,处理它所拥有的所有引用(包括自引用),这会导致它自行处理.
这有意义吗?
似乎问题出在NinjectHttpApplication中.看看这个激活码:
public void Application_Start()
{
lock (this)
{
kernel = this.CreateKernel();
...
kernel.Bind<IResolutionRoot>().ToConstant(kernel).InSingletonScope();
...
}
}
Run Code Online (Sandbox Code Playgroud)
看起来没问题,但现在发生的事情是每当调用IResolutionRoot时,内核都会缓存在自身内部.在处置内核时,清空缓存会释放所有缓存的对象,从而导致循环引用.
NinjectHttpApplication的一个简单解决方案是简单地更改绑定.将常量绑定更改为方法一:
kernel.Bind<IResolutionRoot>().ToConstant(kernel).InSingletonScope();
Run Code Online (Sandbox Code Playgroud)
变
kernel.Bind<IResolutionRoot>().ToMethod(x => this.Kernel);
Run Code Online (Sandbox Code Playgroud)
这解决了问题,但我不确定整个循环处置缓存问题是否是ninject中的错误.
好吧,我知道HTML中的fieldset/ 是如何legend工作的.假设您有一个包含某些字段的表单:
<form>
<fieldset>
<legend>legend</legend>
<input name="input1" />
</fieldset>
</form>
Run Code Online (Sandbox Code Playgroud)
我该怎么用legend?它被显示为标题,但在语义上不是传说内容的解释?在我看来,最好你做这样的事情:
<form>
<fieldset>
<legend>* = required</legend>
<label for="input1">input 1 *</label><input id="input1" name="input1" />
</fieldset>
</form>
Run Code Online (Sandbox Code Playgroud)
但这并不能解决字段集的呈现方式.这只是HTML中的一个暧昧命名,还是我对英文单词'legend'的误解?
编辑:修正了一些错误;-)
我无法使用多文件夹卷挂载来挂载配置映射。
我的结构volume-mount.yaml如下:
不起作用
apiVersion: v1
kind: Pod
metadata:
name: test-web
spec:
containers:
- name: test-web
image: docker.io/hello-world
volumeMounts:
- name: config-volume
mountPath: /usr/test
volumes:
- name: config-volume
configMap:
name: test-config-map
items:
- key: application.properties
path: test-web
- key: test.xml
path: test-web/configs/test_config
restartPolicy: Never
Run Code Online (Sandbox Code Playgroud)
错误:
MountVolume.SetUp failed for volume "config-volume" : open /var/lib/kubelet/pods/93768c34-6dc6-11e8-9546-025000000001/volumes/kubernetes.io~configmap/config-volume/..2018_06_11_22_27_08.476420050/test-web: is a directory`
Run Code Online (Sandbox Code Playgroud)
作品
apiVersion: v1
kind: Pod
metadata:
name: test-web
spec:
containers:
- name: test-web
image: docker.io/hello-world
volumeMounts:
- name: config-volume
mountPath: /usr/test
volumes: …Run Code Online (Sandbox Code Playgroud) 我们正在构建一个应用程序,为各种业务存储"营业时间".表示此数据的最简单方法是什么,以便您可以轻松检查项目是否已打开?
一些选择:
有没有人有存储和查询时间表信息的经验和任何建议?
(有各种各样的疯狂角落案例,比如"关闭本月的第一个星期二",但我们会将其留下另一天).
至于我收集(读取:测量),到目前为止构建配置和sessionfactory需要花费大量时间使用nhibernate执行查询.是否有任何反对使sessionfactory静态,所以每个appDomain只配置一次?
我知道在使用这种方法时存在锁定和竞争问题,但我个人并不认为在sessionfactory上使用这种方法会破坏我的应用程序.
我问这个的原因是因为它很难测试可能的线程问题,因为它不会一直发生.
c# ×2
asp.net ×1
asp.net-mvc ×1
caching ×1
datetime ×1
docker ×1
fieldset ×1
html ×1
kubernetes ×1
mount ×1
nhibernate ×1
ninject ×1
time ×1