C#(.Net 3.5 SP1)中的以下代码是我机器上的无限循环:
for (float i = 0; i < float.MaxValue; i++) ;
Run Code Online (Sandbox Code Playgroud)
它达到了16777216.0和16777216.0 + 1的评估值为16777216.0.但在这一点上:我+ 1!=我.
这是一些疯狂.
我意识到浮点数的存储方式存在一些不准确之处.而且我已经读过整数大于2 ^ 24而不能正确存储为浮点数.
上面的代码仍然应该在C#中有效,即使数字无法正确表示.
为什么不起作用?
你可以在double中获得同样的效果,但这需要很长时间.9007199254740992.0是double的限制.
我们即将为Windows 8提交两个版本的游戏:
因此,在广告支持的版本上,我们需要一个按钮来链接到商店以获取完整版本.
在这两个版本中,我们还想放置一个按钮来链接到商店以查看每个应用.
如何在Windows 8中处理这两种方案?
我对TransactionScope类感到好奇.
在大多数情况下,我认为它是用于数据库连接(这是我用过的).
我的问题是,您是否可以将任何代码放在TransactionScope的使用块中以使其成为事务性的?MS文档不清楚.
如果它可用于制作除数据库连接以外的代码事务,那么支持哪些代码?如果它可以使System.IO.File操作事务性,那对我来说似乎很疯狂.
假设我有一个实现IBaseClass的类BaseClass
然后我有一个继承IBaseClass的接口IClass.
然后我有一个名为class的类,它实现了IClass.
例如:
[ComVisible(true), InterfaceType(ComInterfaceType.IsDual), Guid("XXXXXXX")]
public interface IBaseClass
{
[PreserveSig]
string GetA()
}
[ComVisible(true), InterfaceType(ComInterfaceType.IsDual), Guid("XXXXXXX")]
public interface IClass : IBaseClass
{
[PreserveSig]
string GetB()
}
[ComVisible(true), ClassInterface(ClassInterfaceType.None), Guid("XXXXXXX")]
public class BaseClass : IBaseClass
{
public string GetA() { return "A"; }
}
[ComVisible(true), ClassInterface(ClassInterfaceType.None), Guid("XXXXXXX")]
public class Class : BaseClass, IClass
{
public string GetB() { return "B"; }
}
Run Code Online (Sandbox Code Playgroud)
当暴露给COM时,如果我创建一个"Class"实例,它就不允许我调用GetA().
在.tlb文件中查找我的IDL时,我的IClass界面如下所示:
[
odl,
uuid(XXXXXXXXXXXXXXXXXXXXX),
version(1.0),
dual,
oleautomation,
]
interface IClass : IDispatch {
[id(0x60020000)]
BSTR GetB(); …Run Code Online (Sandbox Code Playgroud) 我一直在研究.Net 4.0中一些新的并行功能的实用性.
说我有这样的代码:
foreach (var item in myEnumerable)
myDatabase.Insert(item.ConvertToDatabase());
Run Code Online (Sandbox Code Playgroud)
想象一下myDatabase.Insert正在执行一些工作来插入SQL数据库.
从理论上讲,你可以写:
Parallel.ForEach(myEnumerable, item => myDatabase.Insert(item.ConvertToDatabase()));
Run Code Online (Sandbox Code Playgroud)
并自动获得利用多个内核的代码.
但是如果myEnumerable只能通过一个线程进行交互呢?Parallel类是否会通过单个线程进行枚举,并仅将结果分派给循环中的工作线程?
如果myDatabase只能由一个线程进行交互怎么办?在循环的每次迭代中建立数据库连接肯定不会更好.
最后,如果我的"var item"碰巧是UserControl或者必须在UI线程上与之交互的东西呢?
我应该采用什么设计模式来解决这些问题?
在我处理真实世界的应用程序时,切换到Parallel/PLinq/etc并不容易.
我们正在努力将程序集暴露给COM.
除此之外,我们频率使用可空值,例如long?,DateTime?等.这些是泛型类型,不能暴露给COM.
什么是COM的这些数据类型的良好替代品?
我们尝试过以下方法:
//Original CustomerID property in class
public long? CustomerID
{
get;
set;
}
//Explicit COM interface
long IComInterface.CustomerID
{
get { return CustomerID.GetValueOrDefault(); }
set { CustomerID = value; }
}
Run Code Online (Sandbox Code Playgroud)
问题是,我们需要一种通过COM来回传递"null"的方法.使用-1或0之类的数字将不起作用,因为它们也是有效值.
我们不得不使用nullables b/c这些最初来自我们的数据库模式.
在阅读标准.Net用户设置时,我们遇到了罕见的异常(这是VS 2008中"项目属性"中的设置):
System.Configuration.ConfigurationErrorsException was caught
Message="Configuration system failed to initialize"
Source="System.Configuration"
BareMessage="Configuration system failed to initialize"
Line=0
StackTrace:
at System.Configuration.ConfigurationManager.PrepareConfigSystem()
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
at System.Diagnostics.DiagnosticsConfiguration.Initialize()
at System.Diagnostics.DiagnosticsConfiguration.get_IndentSize()
at System.Diagnostics.TraceInternal.InitializeSettings()
at System.Diagnostics.TraceInternal.get_Listeners()
InnerException: System.Configuration.ConfigurationErrorsException
Message="Unexpected end of file has occurred. The following elements are not closed: setting, SettingsTest.Properties.Settings, userSettings, configuration. Line 7, position 1. (C:\\Documents and Settings\\USER\\Local Settings\\Application Data\\Hitcents\\SettingsTest.vshost.exe_Url_ghwhc20utv4toanuinmj0pfsljthcugo\\1.0.0.0\\user.config line 7)"
Source="System.Configuration"
BareMessage="Unexpected end of file has occurred. The following elements are not closed: setting, SettingsTest.Properties.Settings, …Run Code Online (Sandbox Code Playgroud) 我们需要授予用户对已安装服务的"启动","停止"和"查询"状态的权限.
在WiX 2.0中,这个xml会起作用:
<ServiceInstall
Id="ServiceInstaller" Type="ownProcess"
Name="$(var.ServiceName)" DisplayName="$(var.ServiceName)" Description="Our service description"
Start="demand" Account="LocalSystem" ErrorControl="ignore" Interactive="no">
<Permission User="Everyone" ServiceQueryStatus="yes" ServiceStart="yes" ServiceStop="yes" />
</ServiceInstall>
<ServiceControl Id="StopService" Stop="both" Remove="uninstall" Name="$(var.OmniVpnServiceName)" Wait="yes" />
Run Code Online (Sandbox Code Playgroud)
我们正在使用WiX 3.0,他们从Permission元素中删除了Service*属性,并且不再允许它成为ServiceInstall元素的子元素.
我们如何在WiX 3.0中获得相同的效果?
作为概述,我们需要:
安装服务:
授予"Everyone"用户访问权限:
在已安装的服务上.
我在MonoTouch中寻找url escape和unescape函数.基本上我正在寻找方法stringByReplacingPercentEscapesUsingEncoding的MonoTouch等价物,如在objective-c代码的以下行中:
NSString *args = [(NSString*)[components objectAtIndex:3]
stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
Run Code Online (Sandbox Code Playgroud)
我本以期能够将其翻译成这样的东西:
string args = URL.Unescape(components[3]);
Run Code Online (Sandbox Code Playgroud)
MonoTouch中是否存在URL转义/ unescape函数,还是我必须自己滚动?
有没有一种理智的方式来开发跨平台的移动应用程序?我们希望这些是每个平台上的本机应用程序,而不一定是某种类型的网页.
目前我们正在考虑将其拆分为两种语言:
我们最初也可以在C#中开发并使用其中一个转换工具将我们的C#转换为Java作为起点.
还有另一种方法吗?我们的技能组合主要包括强大的C#.Net背景和较小的Java经验.
我们真的不想进入低级别并使用类似C/C++的东西来完成工作.这些通常是与某些Web服务通信的简单LOB应用程序.
侧面问题:游戏开发者如何喜欢"愤怒的小鸟"的制作者呢?
更新:
MonoDroid现已正式发布.因此,您似乎只需要将Java用于BlackBerry.我们正在考虑根本不开发BlackBerry,因为已经简化了针对其他3个平台的开发.肯定会有一些成本,因为MonoTouch和MonoDroid都是399美元,你还需要一个Visual Studio许可证(这不包括App Store的成本等).
.net ×8
c# ×8
com ×2
android ×1
blackberry ×1
double ×1
inheritance ×1
iphone ×1
loops ×1
mobile ×1
monodevelop ×1
nullable ×1
settings ×1
transactions ×1
windows-8 ×1
wix ×1
xamarin.ios ×1
xaml ×1