OpenFileOrFolderDialog icon indicating copy to clipboard operation
OpenFileOrFolderDialog copied to clipboard

Does not compile in Visual Studio 2012

Open Bhramar opened this issue 12 years ago • 10 comments

I am trying to compile and build the Project in Visul Studio 2012 . But it does not compile .

Following is the error:

Error 1 The command ""C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\rc.exe" /i "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include" /i "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\include" /r /fo "obj\Debug\res1.res" res1.rc" exited with code 9009. C:\Users\Bhramar\Downloads\OpenFileOrFolderDialog-master\OpenFileOrFolderDialog-master\WindowsFormsApplication1.csproj 104 5 WindowsFormsApplication1

Bhramar avatar Sep 20 '13 10:09 Bhramar

You need manual text edit project file and replace folder reference to direct path. In my 2010 VS was:

   <VCIncludePath Condition="'$(VCIncludePath)' == ''">C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include</VCIncludePath>
    <Win32Resource>$(IntermediateOutputPath)\res1.res</Win32Resource>
  </PropertyGroup>
  <Target Name="BeforeBuild" DependsOnTargets="GetFrameworkPaths;PrepareForBuild">
    <Exec Command="&quot;$(FrameworkSDKDir)\bin\rc.exe&quot; /i &quot;$(VCIncludePath)&quot; /i &quot;$(FrameworkSDKDir)\include&quot; /r /fo &quot;$(IntermediateOutputPath)\res1.res&quot; res1.rc" />
  </Target>    

became:

    <VCIncludePath Condition="'$(VCIncludePath)' == ''">C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include</VCIncludePath>
    <Win32Resource>C:\_Projects\_TestApps\OpenFileOrFolderDialog-master\obj\Debug\res1.res</Win32Resource>
  </PropertyGroup>
  <Target Name="BeforeBuild" DependsOnTargets="GetFrameworkPaths;PrepareForBuild">
    <Exec Command="&quot;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\rc.exe&quot; /i &quot;$(VCIncludePath)&quot; /i &quot;$(FrameworkSDKDir)\include&quot; /r /fo &quot;$(IntermediateOutputPath)\res1.res&quot; res1.rc" />
  </Target>

k-samsonov avatar Oct 14 '13 08:10 k-samsonov

Same problem on Windows 10 with VS 2017. After attempting to fix the paths, I still get these errors:

Severity Code Description Project File Line Suppression State Error cannot open include file 'afxres.h'. WindowsFormsApplication1 C:\Users\scott\source\repos\OpenFileOrFolderDialog-master\res1.rc 32 Error The command ""C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x86\rc.exe" /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include" /i "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\include" /r /fo "obj\Debug\res1.res" res1.rc" exited with code 1. WindowsFormsApplication1 C:\Users\scott\source\repos\OpenFileOrFolderDialog-master\WindowsFormsApplication1.csproj 129

ScottHutchinson avatar Nov 12 '17 20:11 ScottHutchinson

@ScottHutchinson I'm getting the same error here. Have you solved it? In case you didn't, how did you go about creating an "Open File or Folder" dialog box?

GarkGarcia avatar Jul 19 '18 23:07 GarkGarcia

I don't recall anything about this at the moment. But I suspect this path is incorrect: "obj\Debug\res1.res"

And these related lines might need fixing:

https://github.com/scottwis/OpenFileOrFolderDialog/blob/master/WindowsFormsApplication1.csproj#L94

https://github.com/scottwis/OpenFileOrFolderDialog/blob/master/WindowsFormsApplication1.csproj#L97

ScottHutchinson avatar Jul 19 '18 23:07 ScottHutchinson

It turns out that the Output window shows this error '"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\\bin\rc.exe"' is not recognized as an internal or external command.

I got it to build by commenting out the Target Name="BeforeBuild" element in the .csproj file. And then I manually compiled the res1.res file using rc.exe res1.rc and updated the WindowsFormsApplication1 properties...Application...Resource file path to where the res1.res file is actually located.

However, when I run it I get a System.OverflowException.

And I still don't remember why I wanted this dialog to begin with.

ScottHutchinson avatar Jul 20 '18 01:07 ScottHutchinson

Now looking at the source code, I would be surprised if this project was worth debugging.

@GarkGarcia Maybe if you tell me what it is you need, I could help you find a better solution.

ScottHutchinson avatar Jul 20 '18 01:07 ScottHutchinson

@ScottHutchinson I simply need to create a dialog box for browsing and selecting folders. I know I could use FolderBrowserDialog class, but I want it to look and behave — on the user's perspective — the same as the OpenFileDialog class. Thank you for your attention.

GarkGarcia avatar Jul 20 '18 14:07 GarkGarcia

@GarkGarcia In Visual C++ with MFC, I use the CFolderPickerDialog class defined in the afxdlgs.h file.

In .NET, I use this:

// The VistaFolderBrowserDialog control is from http://www.ookii.org/software/dialogs/ open Ookii.Dialogs.Wpf new VistaFolderBrowserDialog()

ScottHutchinson avatar Jul 20 '18 19:07 ScottHutchinson

You get an overflow exception because you need to change hWnd.SendMessage(msg, InteropUtil.NumberOfFileChars, unchecked((uint)buffer)); to hWnd.SendMessage(msg, InteropUtil.NumberOfFileChars, unchecked((ulong)buffer));

Obviously change the function signature too.

ephr4321 avatar Nov 05 '18 14:11 ephr4321

Regarding compiling it - The project as is get compiled with VS2008. After compiling it you can copy the res1.res into the obj/debug (or obj/release etc...) path Also remove from the project file: <Target Name="BeforeBuild" DependsOnTargets="GetFrameworkPaths;PrepareForBuild"> <Exec Command=""$(FrameworkSDKDir)\bin\rc.exe" /i "$(VCIncludePath)" /i "$(FrameworkSDKDir)\include" /r /fo "$(IntermediateOutputPath)\res1.res" res1.rc" /> </Target>

Make the class public and make it class Library - and there you go.

ephr4321 avatar Nov 05 '18 15:11 ephr4321