如何开始从code的Windows Azure存储模拟器V3.0 [英] How to start Windows Azure Storage Emulator V3.0 from code

查看:226
本文介绍了如何开始从code的Windows Azure存储模拟器V3.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从我安装了新的Windows Azure SDK 2.3我得到了一个警告从csrun:

Since I installed the new Windows Azure SDK 2.3 I got a warning from csrun:

通过CSRun DevStore互动已经depricated,使用WAStorageEmulator.exe吧。

"DevStore interaction through CSRun has been depricated. Use WAStorageEmulator.exe instead."

因此​​,有两个问题:
1)如何从code正确地启动新的存储模拟器?
2)如何从code确定存储模拟器已经运行?

So there are two questions: 1) How to start the new storage emulator correctly from code? 2) How to determine from code if the storage emulator is already running?

推荐答案

我找到了自己的解决方案。这里是我的C#code。用于SDK 2.2的老code被注释掉了。

I found the solution myself. Here is my C# code. The old code used for SDK 2.2 is commented out.

public static void StartStorageEmulator()
{
    //var count = Process.GetProcessesByName("DSServiceLDB").Length;
    //if (count == 0)
    //  ExecuteCSRun("/devstore:start");
    var count = Process.GetProcessesByName("WAStorageEmulator").Length;
    if (count == 0)
        ExecuteWAStorageEmulator("start");
}

/*
private static void ExecuteCSRun(string argument)
{
    var start = new ProcessStartInfo
    {
        Arguments = argument,
        FileName = @"c:\Program Files\Microsoft SDKs\Windows Azure\Emulator\csrun.exe"
    };
var exitCode = ExecuteProcess(start);
Assert.AreEqual(exitCode, 0, "Error {0} executing {1} {2}", exitCode, start.FileName, start.Arguments);
}
*/

private static void ExecuteWAStorageEmulator(string argument)
{
    var start = new ProcessStartInfo
    {
        Arguments = argument,
        FileName = @"c:\Program Files (x86)\Microsoft SDKs\Windows Azure\Storage Emulator\WAStorageEmulator.exe"
    };
    var exitCode = ExecuteProcess(start);
    Assert.AreEqual(exitCode, 0, "Error {0} executing {1} {2}", exitCode, start.FileName, start.Arguments);
}

private static int ExecuteProcess(ProcessStartInfo start)
{
    int exitCode;
    using (var proc = new Process { StartInfo = start })
    {
        proc.Start();
        proc.WaitForExit();
        exitCode = proc.ExitCode;
    }
    return exitCode;
}

这篇关于如何开始从code的Windows Azure存储模拟器V3.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆