首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试使用CoreCon应用编程接口连接到设备时获取DirectoryNotFoundException

尝试使用CoreCon应用编程接口连接到设备时获取DirectoryNotFoundException
EN

Stack Overflow用户
提问于 2008-08-09 20:22:19
回答 4查看 1.9K关注 0票数 4

我正在尝试使用Visual Studio2008中的CoreCon API以编程方式启动设备模拟器。当我调用device.Connect()时,莫名其妙地得到了一个DirectoryNotFoundException。如果我在PowerShell或C#控制台应用程序中尝试它,我会得到它。下面是我使用的代码:

代码语言:javascript
复制
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中进行配置。

下面是堆栈跟踪:

代码语言:javascript
复制
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()
EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2010-03-08 20:20:52

它可以在<systemdrive>:\Program files\Common Files\Microsoft Shared\CoreCon\1.0\Bin上找到。

这是您可以获取此dll的路径,因此将此dll添加到您的项目中。

票数 1
EN

Stack Overflow用户

发布于 2008-08-14 00:43:50

安装VS2008SP1为我修复了这个问题。

票数 1
EN

Stack Overflow用户

发布于 2008-08-09 22:04:42

我试过了,它工作得很好。你能粘贴整个异常和堆栈跟踪吗?

更新:奇怪的是,除了在c:\windows\assembly\GAC_MSIL文件夹下,我在我的机器上也找不到那个互操作组件。

为什么不启动SysInternals FileMon或进程监视器,它将省去一些猜测工作。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6904

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档