Visual Studio 2013发布WinForm程序运行报错求助
CLR20r3 FileNotFoundException on Windows 7 SP1 x64 Hey there, let's dig into the likely publishing-related issues that are causing your CLR20r3 error with System.IO.FileNotFoundException when running your VS2013/.NET 4.5.2 WinForm app on the target Windows 7 machine. Here are the most common culprits:
1. Missing Dependencies in the Published Package
This is the top suspect for your error, given the mention of CefSharp DLLs and Newtonsoft.Json.dll:
- NuGet Package Copy Local Settings: For NuGet packages like Newtonsoft.Json and CefSharp, check if their references in your project have
Copy Localset toTrue. If this is disabled, Visual Studio won't copy the DLLs to your output directory, so they won't be included in the installation package. - CefSharp's Extra Files: CefSharp isn't just a set of DLLs—it requires additional resources like
icudtl.dat, thelocalesfolder, and platform-specific CEF binaries. These often don't get automatically picked up by VS's default publish process. You'll need to add these files to your project explicitly, set theirCopy to Output Directoryproperty toCopy if newer, and ensure they're included in your installation package. - Private DLLs for
VAScanProducts.exe: If your main executable has any custom private DLL dependencies, make sure those are also being copied to the output and included in the publish package.
2. Mismatched Target Platform Configuration
- If your project is set to
Any CPUbut hasPrefer 32-bitenabled, it might be trying to load 32-bit CefSharp DLLs on the 64-bit Windows 7 machine (or vice versa if you targeted x64 but the app is running in 32-bit mode). Double-check your project's Build settings: align the target platform (x86/x64) with the CefSharp binaries you're using, and ensure the publish process packages the correct architecture's files.
3. Incorrect Publish Profile Settings
- Open your publish profile (
.pubxmlfile) and verify that you haven't accidentally excluded any of the missing DLLs or CefSharp resources. If you're using ClickOnce, make sure all required dependencies are marked asRequiredin the publish wizard, and that you've enabled the option to include all necessary files from your project directory. - If you're using a third-party installer (like InstallShield or WiX), confirm that the installer project is configured to pull all output files (including the dependent DLLs and CefSharp resources) from your build directory.
4. .NET Framework Installation on Target Machine (Secondary Check)
While your error is a file-not-found issue, it's worth confirming that the Windows 7 machine has a fully installed and working .NET Framework 4.5.2. Sometimes partial installations or corrupted framework files can lead to unexpected load failures, even if the DLLs are present. You can run the .NET Framework Repair Tool to rule this out.
Quick Fix Steps to Test
- Manually copy all the missing DLLs (and CefSharp resources) from your local build output directory to the installed app's folder on the Windows 7 machine. If the app runs, you know the issue is that these files weren't included in the publish package.
- Temporarily set your project's target platform to match the target machine (x64) and re-publish, then test again.
内容的提问来源于stack exchange,提问作者YosiFZ

