我正在修改本文的演示应用程序:http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
我需要更新所有文件以使用我的命名空间,例如现在位于此处的文件:
MySolution\MyApp\DemoApp\ViewModel\MainWindowViewModel.cs
Run Code Online (Sandbox Code Playgroud)
使用这样的命名空间:
namespace DemoApp.ViewModel
{
/// <summary>
/// The ViewModel for the application's main window.
/// </summary>
public class MainWindowViewModel : WorkspaceViewModel
Run Code Online (Sandbox Code Playgroud)
我需要在这里移动文件(删除DemoApp文件夹):
MySolution\MyApp\ViewModel\MainWindowViewModel.cs
Run Code Online (Sandbox Code Playgroud)
并使用正确的命名空间:
namespace MyApp.ViewModel
{
....
Run Code Online (Sandbox Code Playgroud)
如何在visual studio 2010中做到这一点?
在这里更新确定可能重复在Visual Studio中更改项目命名空间现在我知道如何更改项目的命名空间,但如何在文件系统上移动文件?(摆脱"DemoApp"文件夹)
我正在寻找WCF命名管道的最小示例(我期望两个最小的应用程序,服务器和客户端,它们可以通过命名管道进行通信.)
Microsoft有一篇很好的文章" 入门教程",它通过HTTP描述了WCF,我正在寻找类似于WCF和命名管道的东西.
我在互联网上发现了几个帖子,但它们有点"先进".我需要一些最小的,只有强制性的功能,所以我可以添加我的代码并使应用程序正常工作.
如何替换它以使用命名管道?
<endpoint address="http://localhost:8000/ServiceModelSamples/Service/CalculatorService"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICalculator"
contract="ICalculator" name="WSHttpBinding_ICalculator">
<identity>
<userPrincipalName value="OlegPc\Oleg" />
</identity>
</endpoint>
Run Code Online (Sandbox Code Playgroud)
如何替换它以使用命名管道?
// Step 1 of the address configuration procedure: Create a URI to serve as the base address.
Uri baseAddress = new Uri("http://localhost:8000/ServiceModelSamples/Service");
// Step 2 of the hosting procedure: Create ServiceHost
ServiceHost selfHost = new ServiceHost(typeof(CalculatorService), baseAddress);
try
{
// Step 3 of the hosting procedure: Add a service endpoint.
selfHost.AddServiceEndpoint(
typeof(ICalculator),
new WSHttpBinding(),
"CalculatorService");
// Step 4 of the hosting …Run Code Online (Sandbox Code Playgroud) 我的项目遗失了System.Windows.Interactivity.谷歌说我必须安装Expression Blend,但是在我的另一台电脑上我有这个库,我没有安装Expression Blend.那么应该有另一种方式获得System.Windows.Interactivity?我该怎么办?(现在我没有另一台电脑所以我不能只复制这个库:)
:("冒号")在regexp中有特殊含义,但我需要按原样使用它,就像[A-Za-z0-9.,-:]*.我试图逃避它,但这不起作用[A-Za-z0-9.,-\:]*
在我的项目中,我发现了一个在C#中看起来完全有效的奇怪情况,因为我没有编译错误.
简化示例如下所示:
using System;
using System.Collections.Generic;
namespace Test
{
interface IFoo
{
void FooMethod();
}
class A
{
public void FooMethod()
{
Console.WriteLine("implementation");
}
}
class B : A, IFoo
{
}
class Program
{
static void Main(string[] args)
{
IFoo foo = new B();
foo.FooMethod();
}
}
}
Run Code Online (Sandbox Code Playgroud)
这样的代码编译.但是,请注意,A是不是IFoo和B未实现IFoo的方法.在我的情况下,偶然(重构后),A具有相同签名的方法.但是,为什么要A知道如何实现FooMethod的的IFoo接口?A甚至不知道IFoo存在.
对我来说,这样的设计是危险的.因为每次我实现一些接口时,我应检查此接口中的每个方法是否"干扰"基类方法.
如果这是"纯C#功能"?这叫什么?我错过了什么吗?
我有这样的代码:
if (a() && b != null) {
b.doSomething();
}
Run Code Online (Sandbox Code Playgroud)
a()即使b是,我也需要副作用null.它是由C#保证的吗?或者C#可以省略a()呼叫,如果b是null?
我在调试器中遇到这样的问题,程序停止执行.调试器没有显示该行,所以我不知道要修复什么.
mscorlib.dll中发生了未处理的"System.AggregateException"类型异常
附加信息:通过等待任务或访问其Exception属性未观察到任务的异常.结果,终结器线程重新抛出了未观察到的异常.
无法获得本地或参数''的值,因为它在此指令指针处不可用,可能是因为它已经被优化掉了.System.Threading.Tasks.TaskExceptionHolder
如何解决我的问题?
我还发现这个非常相似的问题无法获得本地或参数的值,因为它在此指令指针处不可用,可能是因为它已被优化掉了
我在Java中需要一个可变的布尔字段(稍后我将通过get*方法返回此字段,并且应该可以修改此字段).
布尔值不起作用,因为布尔类中没有set*方法(我会说布尔值是不可变的,你只能改变引用,但你不能改变对象本身).
我想我可以使用大小为1的布尔数组.但是可能有更优雅的解决方案?
为什么Java没有这么简单的东西?
如何打开警告/信息/错误对话框?
我需要带有"确定"按钮和"红叉"图像的标准错误对话框.即模拟org.eclipse.jface.dialogs.MessageDialog.openError()
Math.Ceiling返回double因为double可能存储更大的数字.但是,如果我确定该int类型能够存储结果我应该如何转换?施放是否安全(int) Math.Ceiling(...?