2011-07-26 18 views
5

私は(ビジュアルC#Expressの2010または2010のVisual Studioの究極のいずれかから)C#コンソールアプリケーションを実行するたびに「システムは指定されたパスを見つけることができない」、出力の最初の行はすべてのC#コンソールアプリケーションを印刷

です

私のプログラムが何もしない場合でも、指定されたパスをシステムが見つけることができません

なぜこれが起こるのだろうか?探しているパスが何であるかを確認する方法はありますか?そうでなければプログラムは正常に動作します。私はSystem.IO.DirectoryNotFoundExceptionをキャッチしようとしましたが、try/catchブロックをどこに置くべきかを特定できませんでした。

は、私はいくつかの他のを持ってきた、常に同じ

を取得し、コンソールアプリケーションを構築、Windows 7のx64のを実行している、およびVisual Studioで私ができるすべての異なったプラットフォームターゲット(のx86、x64の、AnyCPU)を試してみました私はそれを理解しようとしている理由です。ありがとう!以下は

EDIT

<?xml version="1.0" encoding="utf-8"?> 
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 
    <PropertyGroup> 
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 
    <Platform Condition=" '$(Platform)' == '' ">x86</Platform> 
    <ProductVersion>8.0.30703</ProductVersion> 
    <SchemaVersion>2.0</SchemaVersion> 
    <ProjectGuid>{04EC9A5E-74D8-4A5F-BCD3-05D9B6CA1477}</ProjectGuid> 
    <OutputType>Exe</OutputType> 
    <AppDesignerFolder>Properties</AppDesignerFolder> 
    <RootNamespace>UsingNLOpt</RootNamespace> 
    <AssemblyName>UsingNLOpt</AssemblyName> 
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> 
    <TargetFrameworkProfile>Client</TargetFrameworkProfile> 
    <FileAlignment>512</FileAlignment> 
    </PropertyGroup> 
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> 
    <PlatformTarget>x86</PlatformTarget> 
    <DebugSymbols>true</DebugSymbols> 
    <DebugType>full</DebugType> 
    <Optimize>false</Optimize> 
    <OutputPath>bin\Debug\</OutputPath> 
    <DefineConstants>DEBUG;TRACE</DefineConstants> 
    <ErrorReport>prompt</ErrorReport> 
    <WarningLevel>4</WarningLevel> 
    </PropertyGroup> 
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> 
    <PlatformTarget>AnyCPU</PlatformTarget> 
    <DebugType>pdbonly</DebugType> 
    <Optimize>true</Optimize> 
    <OutputPath>bin\Release\</OutputPath> 
    <DefineConstants>TRACE</DefineConstants> 
    <ErrorReport>prompt</ErrorReport> 
    <WarningLevel>4</WarningLevel> 
    <AllowUnsafeBlocks>false</AllowUnsafeBlocks> 
    </PropertyGroup> 
    <ItemGroup> 
    <Reference Include="System" /> 
    <Reference Include="System.Core" /> 
    <Reference Include="System.Xml.Linq" /> 
    <Reference Include="System.Data.DataSetExtensions" /> 
    <Reference Include="Microsoft.CSharp" /> 
    <Reference Include="System.Data" /> 
    <Reference Include="System.Xml" /> 
    </ItemGroup> 
    <ItemGroup> 
    <Compile Include="Program.cs" /> 
    <Compile Include="Properties\AssemblyInfo.cs" /> 
    </ItemGroup> 
    <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 
    <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
     Other similar extension points exist, see Microsoft.Common.targets. 
    <Target Name="BeforeBuild"> 
    </Target> 
    <Target Name="AfterBuild"> 
    </Target> 
    --> 
</Project> 

(このプロジェクトは、コマンドラインまたはときVSから実行から実行したとき、私は説明しています問題行動を表示)Visual Studioが発生したことをZ .csprojファイルです。解決済み - Microsoft Consoleのレジストリに存在しないディレクトリへの自動実行エントリ。以下の答えを見てください。 HKEY_LOCAL_MACHINEとHKEY_CURRENT_USERハイブの両方で

\Software\Microsoft\Command Processor\AutoRun 

+0

あなたは私たちにいくつかのコードを示すことができましたか? –

+3

スタートメニューからcmdを実行するとどうなりますか?同じこと? –

+0

実行しているコードは何ですか?そしてスタックトレース? – Carra

答えて

7

あなたがあなたのレジストリを確認することができますか?

これは、コマンドプロセッサが存在しない、起動時に何かを実行しようとしていることかもしれません。

+0

あなたはそれを持っています。ありがとうございました。存在しないHKEY_CURRENT_USERにAutorunエントリがありました。ドライブレター(H :)は私のシステムには一度もなかったので、私は読み書きできませんでした。私は何かをインストールするときにレジストリに書き込んだと仮定します。 – Rory

+0

優れています。私が以前に遭遇した問題ではありませんが、それは疑いようにそのように聞こえました。今日私は "売春宿"ですので、[同意する]ボタンをクリックしてください。 –

関連する問題