我正在尝试使用Visual Studio2008中的CoreCon API以编程方式启动设备模拟器。当我调用device.Connect()时,莫名其妙地得到了一个DirectoryNotFoundException。如果我在PowerShell或C#控制台应用程序中尝试它,我会得到它。下面是我使用的代码:
static void Main(string[] args)
{
DatastoreManager dm = new DatastoreManager(1033);
Collection<Platform> platforms = dm.GetPlatforms();
foreach (var p in platforms)
{
Console.WriteLine("{0} {1}", p.Name, p.Id);
}
Platform platform = platforms[3];
Console.WriteLine("Selected {0}", platform.Name);
Device device = platform.GetDevices()[0];
device.Connect();
Console.WriteLine("Device Connected");
SystemInfo info = device.GetSystemInfo();
Console.WriteLine("System OS Version:{0}.{1}.{2}",info.OSMajor, info.OSMinor, info.OSBuildNo);
Console.ReadLine();
}有人知道我为什么会收到这个错误吗?我在32位的WinXP上运行这个程序,简简单单的Visual Studio2008Pro。我想这是一些配置问题,因为我不能从控制台应用程序或PowerShell中进行配置。
下面是堆栈跟踪:
System.IO.DirectoryNotFoundException was unhandled
Message="The system cannot find the path specified.\r\n"
Source="Device Connection Manager"
StackTrace:
at Microsoft.VisualStudio.DeviceConnectivity.Interop.ConManServerClass.ConnectDevice()
at Microsoft.SmartDevice.Connectivity.Device.Connect()
at ConsoleApplication1.Program.Main(String[] args) in C:\Documents and Settings\Thomas\Local Settings\Application Data\Temporary Projects\ConsoleApplication1\Program.cs:line 23
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()发布于 2010-03-08 20:20:52
它可以在<systemdrive>:\Program files\Common Files\Microsoft Shared\CoreCon\1.0\Bin上找到。
这是您可以获取此dll的路径,因此将此dll添加到您的项目中。
发布于 2008-08-14 00:43:50
安装VS2008SP1为我修复了这个问题。
发布于 2008-08-09 22:04:42
我试过了,它工作得很好。你能粘贴整个异常和堆栈跟踪吗?
更新:奇怪的是,除了在c:\windows\assembly\GAC_MSIL文件夹下,我在我的机器上也找不到那个互操作组件。
为什么不启动SysInternals FileMon或进程监视器,它将省去一些猜测工作。
https://stackoverflow.com/questions/6904
复制相似问题