我在设置我的vwd 2010环境时遇到了一些麻烦,无法在我的本地iis 7.5而不是iis express下运行.
每当我转到项目属性并选择"web"选项卡时,我选择"服务器","本地iis Web服务器".它会自动放入项目URL http:// localhost/myprojectname.
我单击创建虚拟目录,它出现此警告,,,
'无法创建虚拟目录.url http:// localhost/myprojectname的站点存在于本地IIS Web服务器和IIS Express Web服务器上.您需要编辑'c:\ Users\Mike\Documents\iisexpress\config\applicationhost.config'文件来更改iis express使用的端口号,或使用iis manager更改iis中的站点绑定.
在解释为什么我不能使用内置功能来使用iis 7.5而不是iis express时,非常感谢您的帮助.
先感谢您.
我提供了一个简单的代码,它将输出10个随机数字,介于0和100之间.当我在Visual Studio(C#)中使用F5运行时,我获得相同的数字10次.但是,如果我通过调试模式,使用F10或F11逐行运行它,我得到10个不同的数字(可能不是全部不同,但它们是随机的).
public static void rand() {
for (int j = 0; j < 10; j++) {
Random r = new Random();
Console.WriteLine( r.Next(100));
}
}
Run Code Online (Sandbox Code Playgroud)
我知道如何解决这个问题,这是通过在循环外部实例化Random r并通过引用进行复制,但我想了解为什么会发生这种情况.我认为这与种子有关但程序在调试模式下运行时会起作用,这让我很困惑.
此外,现在我正在质疑我是否总是需要测试调试模式是否给我正确的结果.
我有一个可拖动的类继承UIImageView.当视图没有动画时,拖动工作正常.但是当它动画时它不会响应触摸.动画完成后,触摸再次起作用.但我需要它在触摸时暂停动画并在触摸结束时恢复.我花了一整天研究它,但无法弄清楚原因.
这是我的动画代码.
[UIView animateWithDuration:5.0f
delay:0
options:(UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction)
animations:^{
self.center = CGPointMake(160,240);
self.transform = CGAffineTransformIdentity;
}
completion:nil
];
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
NSLog(@"touch");
CGPoint pt = [[touches anyObject] locationInView:self];
startLocation = pt;
[self.layer removeAllAnimations];
[[self superview] bringSubviewToFront:self];
}
Run Code Online (Sandbox Code Playgroud) 我们有一个来自另一个项目的.NET程序集,其中一个来自Reflector的生成文件有一个方法的代码片段.
现在VS 2010 c#编译器抛出各种编译错误$$意外.关闭括号等
在ILDASM中,我看到了这个方法以及许多其他提到的方法,但是在生成的代码中,我发现只有这些编译器生成的方法中的一个进入.
怎么去编译?
我有以下界面
public interface IHandler<T>
{
void Handle(T myObject);
}
Run Code Online (Sandbox Code Playgroud)
我希望有一个HandlersManager类,它包含对象类型与相应处理程序之间的映射,但我不确定我应该如何定义保存此映射的对象.
例如,我想要的是:
typeof(string) --> instance of IHandler<string>
typeof(MyClass) --> instance of IHandler<MyClass>
Run Code Online (Sandbox Code Playgroud)
到目前为止,我得到的最好的事情是Dictionary<Type, object>为映射定义,但在这种情况下,我必须在IHandler<T>每次获取它时将值转换为值.
有没有更好的解决方案或我完全错过的东西?
我有两个测试类,MyFirstTest和MySecondTest.独立运行每个工作正常.当我同时运行时(在eclipse中选择包含这些文件的测试文件夹,右键单击,以junit运行),MySecondTest失败,因为MyClass在运行其测试时仍然被模拟.MyFirstTest需要模拟MyClass.MySecondTest要求MyClass不被嘲笑.我认为tearDownMocks假设"移除"类.
public class MyFirstTest {
@Before
public void setUp() throws Exception {
Mockit.setUpMocks(MockMyClass.class);
}
@After
public void tearDown() throws Exception {
Mockit.tearDownMocks(MockMyClass.class);
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
Mockit.tearDownMocks(MockMyClass.class);
}
@MockClass(realClass = MyClass.class, stubs = "<clinit>")
public static class MockMyClass {
...
public class MySecondTest {
Run Code Online (Sandbox Code Playgroud) 声明并启动以下流程后:
System.Diagnostics.Process _p = new System.Diagnostics.Process();
.....
.....
....
_p.Start();
Run Code Online (Sandbox Code Playgroud)
现在有两种可能性:输出或错误.
如果发生错误,是否有Process类的属性可以通过它来确定是否发生错误?
我正在重定向标准输出,我不想在MSDN中警告重定向标准错误.我也不想使用:BeginOutputReadLine();
还有其他选择吗?
谢谢.
例如HttpWebResponse,我有一个实现的对象,IDisposable因此应该被处理掉.
有这个:
HttpWebResponse a = ....;
Run Code Online (Sandbox Code Playgroud)
处理对象的正确方法是什么?
a.Dispose();
Run Code Online (Sandbox Code Playgroud)
要么:
if (a!= null)
a.Dispose();
Run Code Online (Sandbox Code Playgroud)
我是否应该关心对象是否为空?不管怎样我不能处理它?
我到目前为止的代码如下,我想要解决的是摆脱try-catch:
public static bool IsNeverValidGenericArgument(this Type type) {
var elementType=type.GetElementType();
if(null!=elementType) {
if(type.IsArray)
try {
typeof(IList<>).MakeGenericType(elementType);
return false;
}
catch(ArgumentException) {
}
catch(TypeLoadException) {
}
return true; // pointer or byref
}
return
typeof(void)==type||typeof(RuntimeArgumentHandle)==type
||
typeof(ArgIterator)==type||typeof(TypedReference)==type;
}
Run Code Online (Sandbox Code Playgroud)
我想写的动态结构类型的代码,我的代码将调用GetInterfaces()每种类型过去了,但一些由消费者的代码中传递的类型可能会导致TypeLoadException在RuntimeType内部(如typeof(ArgIterator).MakeArrayType().MakeArrayType()在3.5,而不是4.0+)我需要先检查它是否永远不是一个有效的泛型参数.try-catch有效,但没有好处.
请注意,它抛出的情况可能因.Net框架的不同版本而异.
编辑:
该方法的替代版本是:
public static bool IsNeverValidGenericArgument(this Type type) {
var elementType=type.GetElementType();
if(null!=elementType) {
if(type.IsArray)
return elementType.IsNeverValidGenericArgument();
return true; // pointer or byref
}
return
typeof(void)==type||typeof(RuntimeArgumentHandle)==type
||
typeof(ArgIterator)==type||typeof(TypedReference)==type;
}
Run Code Online (Sandbox Code Playgroud)
但是这会报告某些类型无效,实际上不会导致异常 …
我想在我的android程序中显示时区的"名称".如果是"格林尼治标准时间+8:00",则显示"香港"; 通过搜索,我发现getDisplayName函数应该切断我的目的.
但是,在我自己的程序中,此功能仅显示"GMT + 8:00",但当我在Google开源项目中使用"getDisplayName"时,它将显示名称"HongKong".
有谁知道这背后的原因?