在C#.Net MVC2应用程序中,我们有一个简单的函数来获取处理器ID作为识别Web服务器的方案的一部分.相关部分是:
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("select ProcessorId from Win32_Processor"))
{
foreach (ManagementObject share in searcher.Get())
{
foreach (PropertyData PC in share.Properties)
{
return PC.Value.ToString();
}
}
}
Run Code Online (Sandbox Code Playgroud)
它在开发和运行cassini和IIS的许多Web服务器上运行良好.但是,在Server 2008计算机上的最新安装中,它会在第一次调用时抛出Out of Memory Exception以获取处理器ID.有关可能的原因或更好的方法来达到上述目的的任何建议.
非常感谢
编辑以包括堆栈跟踪:
System.Management.ManagementException: Out of memory
at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
at System.Management.ManagementObjectCollection.ManagementObjectEnumerator.MoveNext()
at GIB.Helpers.SoftwarehouseLicenseAttribute.GetProcessorID() in C:\Users\Dog\Documents\Visual Studio 2010\Projects\GIB\GIB\Helpers\SoftwarehouseLicense.cs:line 177
at GIB.Helpers.SoftwarehouseLicenseAttribute.setup() in C:\Users\Dog\Documents\Visual Studio 2010\Projects\GIB\GIB\Helpers\SoftwarehouseLicense.cs:line 75
at GIB.Controllers.HomeController.Setup() in C:\Users\Dog\Documents\Visual Studio 2010\Projects\GIB\GIB\Controllers\HomeController.cs:line 37
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext …
Run Code Online (Sandbox Code Playgroud) 是否有一些关于登录Rails的指南?似乎没有关于该主题的官方指南.Rails有自己的日志记录API,还是内部使用Ruby日志记录系统?
我正在使用Rails 3.
我正在使用Spring MVC,AJAX/JSON和Hibernate从MySQL数据库中获取所有人员.我写了JUnit集成测试来验证我的服务,一切都没问题.
现在我称之为:
@RequestMapping(value="/allpersons", method=RequestMethod.GET)
public @ResponseBody Set<Person> getAllPersons() {
Set<Person> persons= new PersonServiceImpl().getAllPersons();
return persons;
}
Run Code Online (Sandbox Code Playgroud)
我调试了它.这条线
return persons;
Run Code Online (Sandbox Code Playgroud)
一切都好.我有一个包含所有人的HashSet.调试更多步骤,我来到这一行:
this.objectMapper.writeValue(jsonGenerator, o);
Run Code Online (Sandbox Code Playgroud)
在
org.springframework.http.converter.json.MappingJacksonHttpMessageConverter
Run Code Online (Sandbox Code Playgroud)
然后我没有看到源代码,但我的调试器告诉我:
StdSerializerProvider._serializeValue(JsonGenerator, Object) line 297
Run Code Online (Sandbox Code Playgroud)
在这一行之后,我得到错误:
ERROR: org.hibernate.LazyInitializationException - failed to lazily initialize a collection of role: com.mydomain.project.dom.Person.projects, no session or session was closed org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.mydomain.project.dom.Person.projects, no session or session was closed at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:383) at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:375) at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:368) at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:111) at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:186) at org.codehaus.jackson.map.ser.ContainerSerializers$CollectionSerializer.serializeContents(ContainerSerializers.java:339) at org.codehaus.jackson.map.ser.ContainerSerializers$CollectionSerializer.serializeContents(ContainerSerializers.java:314) at …
我在观看Summer of NHibernate教程视频时看到过这个功能; 是否可以在解决方案中复制项目的一些引用并将它们粘贴到Visual Studio中的另一个项目的references文件夹中?
谢谢
我在CruiseControl.NET中运行了几个项目.他们中的许多人没有构建错误并且成功构建.他们都试图在构建之前提取最新的代码.
我注意到他们经常无法建造; CruiseControl报告"例外".SVN 500错误(内部服务器错误)是个例外.它随机但持续地打击(例如,在一个项目中,每个交替构建都失败).
我已经尝试使用相同的凭据检查其中一些零星失败的项目,它的工作原理.我知道项目的构建,因为不是每个构建都失败了.
问题是什么?
对于它的价值,这里是示例性例外的顶线(没有SVN项目URL或凭证):
ThoughtWorks.CruiseControl.Core.CruiseControlException: Source control operation failed: svn: Server sent unexpected return value (500 Internal Server Error) in response to OPTIONS request for 'https://some/url/trunk'
. Process command: C:\Program Files\CollabNet Subversion Client\svn.exe log https://some/url/trunk -r "{2010-12-04T09:09:19Z}:{2010-12-07T09:08:48Z}" --verbose --xml --username ******** --password ******** --non-interactive --no-auth-cache
Run Code Online (Sandbox Code Playgroud)
编辑:有时这似乎是因为本地文件夹中存在SVN冲突.但这并不一致.
赏金:我为此提供了一个通用解决方案的奖励:如何配置CC.NET以优雅地应对SVN错误,即不处理由定期更新检查(与计划的每日构建相反)触发的SVN失败构建故障,但优雅地退回,直到它被修复或直到连接恢复.
我自己没有设法解决这个问题,虽然我不是CC.NET专家,并且没有找很长时间.是否有支持或是否需要编码?谢谢!
澄清,
我有两个整数x
和y
.我需要计算x/y
,结果我想浮动.例如,作为3/2
我希望有1.5的结果.我认为,最简单的(或唯一的)的方式来做到这一点是转换x
和y
成float类型.不幸的是,我找不到一个简单的方法来做到这一点.你能帮帮我吗?
我目前正在使用Kramdown从Ruby中的Markdown生成HTML.我知道我可以使用kramdown生成一个latex文件,并将其转换为pdf美国命令行实用程序.但我想要一个纯粹的红宝石解决方案.
有没有办法在不使用命令行实用程序的情况下仅使用ruby将markdown转换为pdf?
是否可以从数据库刷新django对象的状态?我的意思是行为大致相当于:
new_self = self.__class__.objects.get(pk=self.pk)
for each field of the record:
setattr(self, field, getattr(new_self, field))
Run Code Online (Sandbox Code Playgroud)
更新:在跟踪器中找到了重新打开/未修正的战争:http://code.djangoproject.com/ticket/901 .还是不明白为什么维护者不喜欢这个.
Webmethods Integration Server可以集成系统并从网络上的外部系统编排不同的Web服务.
我的问题是:是否可以创建在Webmethods Integration Server中运行的Java代码,并将其作为Web服务公开?因此,让Webmethods托管Web服务.
我每天都有一个自动生成的文件,由shell脚本调用.但是,我面临的问题是自动生成的文件有以下形式:
FILE_MM_DD.dat
Run Code Online (Sandbox Code Playgroud)
...其中MM和DD是2位数月份和日期字符串.
我做了一些研究,并自己打了它,但我不知道如何只使用shell脚本创建这些自定义字符串.
要清楚,我知道Bash中的DATE函数,但我正在寻找的是C中的SPRINTF函数的等价物.