Visual Studio 2019 configuration the complied .dll assembly does not exist

0

I'm running a project in Visual Studio 2019, where I'm using the CefSharp package, which requires me to set Debug/Release configuration modes as x64.

When I run my project, I get an error that it Failed to Initialize because:

the assemby "C:\myProject\Work\Code\myProject..\myProject.dll" does not exist.

My project folder is:

C:\myProject\Work\Code\myProject\myProject

I've set the mode to Debug and x64, with the Output path as x64\, meaning that it is directed to:

C:\myProject\Work\Code\myProject\myProject\x64

When I check the folder contents, for both of the folder locations mentioned above, they both contain a "myProject.dll" file.

but the error is still there.. even when I place the full path in the Output path, and not just x64\, it still doesn't work.

I'm wondering what could be wrong because even if the .dll is not 'correct', it should still find it.

Thank you

EDIT:

I've tried the solution suggested in the first answer. I've checked the .csproj file, I've deleted the bin/obj/.vs folders and tried what is in the link suggested.

When I restart VS it is on AnyCPU by default. If I build it as such, it compiles without error, but when I run the application it fails and gives the error:

FileNotFoundException: Could not load file or assembly 'CefSharp.Wpf, Version=84.4.10.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138' or one of its dependencies. The system cannot find the file specified.

If instead of building and running as AnyCPU I try to switch to x64, then I get a compile error:

The OutputPath property is not set for project 'BIMbase.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='x64'. This error may also appear if some other project is trying to follow a project-to-project reference to this project, this project has been unloaded or is not included in the solution, and the referencing project does not build using the same or an equivalent Configuration or Platform.

The .csproj as requested:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="..\packages\CefSharp.Wpf.84.4.10\build\CefSharp.Wpf.props" Condition="Exists('..\packages\CefSharp.Wpf.84.4.10\build\CefSharp.Wpf.props')" />
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{8F2295E7-314F-47A7-992C-6756624BF6F6}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>BIMbase</RootNamespace>
    <AssemblyName>BIMbase</AssemblyName>
    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <Deterministic>true</Deterministic>
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
    <TargetFrameworkProfile />
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Latest|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Latest\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x86\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <LangVersion>7.3</LangVersion>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
    <OutputPath>bin\x86\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <Optimize>true</Optimize>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <LangVersion>7.3</LangVersion>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Latest|x86'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x86\Latest\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <DebugType>full</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <LangVersion>7.3</LangVersion>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <PropertyGroup>
    <ApplicationManifest>app.manifest</ApplicationManifest>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="CefSharp, Version=84.4.10.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=AMD64">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\..\..\Users\yafim\.nuget\packages\cefsharp.common\84.4.10\CefSharp\x64\CefSharp.dll</HintPath>
    </Reference>
    <Reference Include="CefSharp.BrowserSubprocess.Core, Version=84.4.10.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=AMD64">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\..\..\Users\yafim\.nuget\packages\cefsharp.common\84.4.10\CefSharp\x64\CefSharp.BrowserSubprocess.Core.dll</HintPath>
    </Reference>
    <Reference Include="CefSharp.Core, Version=84.4.10.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=AMD64">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\..\..\Users\yafim\.nuget\packages\cefsharp.common\84.4.10\CefSharp\x64\CefSharp.Core.dll</HintPath>
    </Reference>
    <Reference Include="CsvHelper, Version=15.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823, processorArchitecture=MSIL">
      <HintPath>..\packages\CsvHelper.15.0.4\lib\net47\CsvHelper.dll</HintPath>
    </Reference>
    <Reference Include="FireSharp, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\packages\FireSharp.2.0.4\lib\portable-net45+sl5+wp8+win8\FireSharp.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.1.1.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Threading.Tasks.Extensions, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.168.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
    </Reference>
    <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
      <HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
    </Reference>
    <Reference Include="PresentationCore" />
    <Reference Include="PresentationFramework" />
    <Reference Include="RevitAPI">
      <HintPath>..\..\..\..\..\Program Files\Autodesk\Revit 2020\RevitAPI.dll</HintPath>
    </Reference>
    <Reference Include="RevitAPIUI">
      <HintPath>..\..\..\..\..\Program Files\Autodesk\Revit 2020\RevitAPIUI.dll</HintPath>
    </Reference>
    <Reference Include="SkiaSharp, Version=1.59.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
      <HintPath>..\packages\SkiaSharp.1.59.1\lib\net45\SkiaSharp.dll</HintPath>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Net" />
    <Reference Include="System.Net.Http.Extensions, Version=2.2.28.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Extensions.dll</HintPath>
    </Reference>
    <Reference Include="System.Net.Http.Primitives, Version=4.2.28.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll</HintPath>
    </Reference>
    <Reference Include="System.Net.Http.WebRequest" />
    <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
    </Reference>
    <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
      <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
    </Reference>
    <Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
      <HintPath>..\packages\System.ValueTuple.4.4.0\lib\net47\System.ValueTuple.dll</HintPath>
      <Private>True</Private>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.Windows.Controls.DataVisualization.Toolkit, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\packages\System.Windows.Controls.DataVisualization.Toolkit.4.0.0.0\lib\net40-Client\System.Windows.Controls.DataVisualization.Toolkit.dll</HintPath>
    </Reference>
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Windows.Forms.DataVisualization" />
    <Reference Include="System.Xaml" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
    <Reference Include="UIAutomationProvider" />
    <Reference Include="WindowsBase" />
    <Reference Include="WindowsFormsIntegration" />
    <Reference Include="Xceed.Wpf.Toolkit, Version=3.8.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
      <HintPath>..\packages\Extended.Wpf.Toolkit.3.8.1\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Browser.cs" />
    <Compile Include="Command.cs" />
    <Compile Include="CurrentStateSelection.cs" />
    <Compile Include="CurrentState.cs" />
    <Compile Include="DataGraphicsDisplay.cs" />
    <Compile Include="DataGraphicsForm.cs">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="DataGraphicsForm.Designer.cs">
      <DependentUpon>DataGraphicsForm.cs</DependentUpon>
    </Compile>
    <Compile Include="GraphPane.xaml.cs">
      <DependentUpon>GraphPane.xaml</DependentUpon>
    </Compile>
    <Compile Include="Main.cs" />
    <Compile Include="Models\HistoryDateSortItem.cs" />
    <Compile Include="Models\HistoryResult.cs" />
    <Compile Include="Models\MatchEntry.cs" />
    <Compile Include="Models\MaterialsCO2.cs" />
    <Compile Include="Models\UnknownMaterial.cs" />
    <Compile Include="Request.cs" />
    <Compile Include="RequestHandler.cs" />
    <Compile Include="SelectionTakeoffCreation.cs" />
    <Compile Include="MaterialTakeoffCreation.cs" />
    <Compile Include="NamePair.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="Properties\Resources.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    <Compile Include="MainWindow.xaml.cs">
      <DependentUpon>MainWindow.xaml</DependentUpon>
    </Compile>
    <Compile Include="Services\FireBase.cs" />
    <Compile Include="ShowUpdate.cs" />
    <Compile Include="UserMaterialDataCollection.cs" />
    <Compile Include="UserMaterialForm.cs">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="UserMaterialForm.Designer.cs">
      <DependentUpon>UserMaterialForm.cs</DependentUpon>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="DataGraphicsForm.resx">
      <DependentUpon>DataGraphicsForm.cs</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
    <EmbeddedResource Include="UserMaterialForm.resx">
      <DependentUpon>UserMaterialForm.cs</DependentUpon>
    </EmbeddedResource>
    <None Include="app.manifest" />
    <None Include="packages.config" />
    <None Include="Properties\DataSources\DataGraphicsForm.datasource" />
    <EmbeddedResource Include="Resources\Mapping 1.csv">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </EmbeddedResource>
    <EmbeddedResource Include="Resources\Mapping 2.csv">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </EmbeddedResource>
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="Resources\BIMbase_logo_16x16.png" />
    <EmbeddedResource Include="Resources\BIMbase_logo_32x32.png" />
    <EmbeddedResource Include="Resources\BIMbase_piechart_16x16.png" />
    <EmbeddedResource Include="Resources\BIMbase_piechart_32x32.png" />
  </ItemGroup>
  <ItemGroup>
    <Page Include="GraphPane.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:Compile</Generator>
    </Page>
    <Page Include="MainWindow.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:Compile</Generator>
    </Page>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <Import Project="..\packages\SkiaSharp.1.59.1\build\net45\SkiaSharp.targets" Condition="Exists('..\packages\SkiaSharp.1.59.1\build\net45\SkiaSharp.targets')" />
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\packages\SkiaSharp.1.59.1\build\net45\SkiaSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\SkiaSharp.1.59.1\build\net45\SkiaSharp.targets'))" />
    <Error Condition="!Exists('..\packages\CefSharp.Wpf.84.4.10\build\CefSharp.Wpf.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CefSharp.Wpf.84.4.10\build\CefSharp.Wpf.props'))" />
    <Error Condition="!Exists('..\packages\CefSharp.Wpf.84.4.10\build\CefSharp.Wpf.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CefSharp.Wpf.84.4.10\build\CefSharp.Wpf.targets'))" />
  </Target>
  <Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
  <Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
    <Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
    <Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
  </Target>
  <Import Project="..\packages\CefSharp.Wpf.84.4.10\build\CefSharp.Wpf.targets" Condition="Exists('..\packages\CefSharp.Wpf.84.4.10\build\CefSharp.Wpf.targets')" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>x64\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <Prefer32Bit>true</Prefer32Bit>
    <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
  </PropertyGroup>
</Project>

So I believe that there might be an issue with the CefSharp package, but I don't know how or if it will help to "restore" it, it seems to compile fine in AnyCPU, but in the x64 where it should actually run correctly, it doesn't compile.

EDIT:

Hi, thank you for the help. I tried 1) and 2) in your Update. It didn't work. Before trying 3), I want to add a few more notes, maybe it will help to understand the issue.

Note: I've completely deleted any trace of CefSharp I could find anywhere.

When running the Webapp, it works find on a LocalHost. When running the actual app with the Client code, I get the full error:

Server Error in '/' Application.

Could not load file or assembly 'CefSharp.BrowserSubprocess.Core' or one of its dependencies. An attempt was made to load a program with an incorrect format. 
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

 Exception Details: System.BadImageFormatException: Could not load file or assembly 'CefSharp.BrowserSubprocess.Core' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Source Error: 

 An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.   

Assembly Load Trace: The following information can be helpful to determine why the assembly 'CefSharp.BrowserSubprocess.Core' could not be loaded.

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Stack Trace: 

[BadImageFormatException: Could not load file or assembly 'CefSharp.BrowserSubprocess.Core' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +37
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +159
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +80
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +22
   System.Reflection.Assembly.Load(String assemblyString) +29
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +39

[ConfigurationErrorsException: Could not load file or assembly 'CefSharp.BrowserSubprocess.Core' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +777
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +229
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +140
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +176
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +99
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +310
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +165
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +590

[HttpException (0x80004005): Could not load file or assembly 'CefSharp.BrowserSubprocess.Core' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10083304
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +99
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +263

Besides that, when I rebuild my project I have some errors/warnings, some of which I think are related to the 1) and 2) steps you mentioned:

1> Consider app.config remapping of assembly "Xceed.Wpf.AvalonDock, Culture=neutral, PublicKeyToken=3e4669d2f30244f4" from Version "2.0.19.10" [C:\Program Files\Autodesk\Revit 2020\Xceed.Wpf.AvalonDock.dll] to Version "3.8.0.0" [C:\BIMbase\Work\Code\BIMbase\packages\Extended.Wpf.Toolkit.3.8.1\lib\net40\Xceed.Wpf.AvalonDock.dll] to solve conflict and get rid of warning.

1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3276: Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property to true in the project file. For more information, see http://go.microsoft.com/fwlink/?LinkId=294190.

And the 2nd error above refers to the code:

false true

No idea why CefSharp error still exists...

c#
dll
configuration
64-bit
visual-studio-debugging
asked on Stack Overflow Oct 20, 2020 by Yafim Simanovsky • edited Oct 23, 2020 by Yafim Simanovsky

1 Answer

1

If you add Configuration with x64, you should try the steps as this answer described.

Suggestion

After that, you should check on your myProject.csproj file and make sure that you have defined the right outputpath for x64 mode.

Add like this:

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>x64\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <LangVersion>7.3</LangVersion>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <Prefer32Bit>true</Prefer32Bit>
  </PropertyGroup>

It will make the outputpath of configuration x64 to:

C:\myProject\Work\Code\myProject\myProject\x64

Besides, check on the file and ensure there are no other configuration x64 conditions of the properties to cause conflict with it. Remember to retain only one like the above one.

===========================================

If you already did all the steps, you could try the following steps:

1) close VS, delete .vs hidden folder under the solution folder C:\myProject\Work\Code\myProject.

also bin and obj folder under the project folder, any x64 folders to make a clean build environment.

2) restart your project to rebuild again to test it.

In addition, if these do not work, I suggest you could share your myProject.csproj file with us to help us troubleshoot the issue more quickly.

=================================

Update 1

Actually, you should build and run your project under X64 or X86 according to CefSharp nuget package's requirements. And you should not build your project under AnyCPU because the nuget package CefSharp.Common needs x64 or x86.

And you should change the platform under Build-->Configuration Manager like this:

enter image description here

1) Besides, you should define the Debug|x64 property alongside with other Configuration, Platform definitions:

..............

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Latest|x86'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x86\Latest\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <DebugType>full</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <LangVersion>7.3</LangVersion>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
    <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
        <DebugSymbols>true</DebugSymbols>
        <OutputPath>x64\</OutputPath>
        <DefineConstants>DEBUG;TRACE</DefineConstants>
        <DebugType>full</DebugType>
        <PlatformTarget>x64</PlatformTarget>
        <ErrorReport>prompt</ErrorReport>
        <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
        <Prefer32Bit>true</Prefer32Bit>
        <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
    </PropertyGroup>

<ItemGroup>
    <Reference Include="CefSharp, Version=84.4.10.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=AMD64">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\..\.nuget\packages\cefsharp.common\84.4.10\CefSharp\x64\CefSharp.dll</HintPath>
    </Reference>
    <Reference Include="CefSharp.BrowserSubprocess.Core, Version=84.4.10.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=AMD64">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\..\.nuget\packages\cefsharp.common\84.4.10\CefSharp\x64\CefSharp.BrowserSubprocess.Core.dll</HintPath>
    </Reference>

..........................

2) run update-package -reinstall under Tools-->Nuget Package Manager-->Package Manager Conosole.

3) When you build your project, try to config like this under Build-->Configuration Manager.

===========================================

Update 2

The workaround is to add bindredirect.

Below are three ways, you could try one of them:

Solution

1) right-click on your project-->Add-->New Item-->select Application Configuration File file template--> and name it as App.config

enter image description here

enter image description here

add these on that file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <runtime>
        <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="CefSharp" publicKeyToken="40c4b6fc221f4138" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-84.4.10.0" newVersion="84.4.10.0" />
            </dependentAssembly>
        </assemblybinding>
    </runtime>
</configuration>

2) or add these xml node under your BIMbase.csproj file:

<PropertyGroup>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>

3) If it doesn't work, you could change packages.config nuget management format to PackageReference nuget management format. The issue always happens on the packages.config while PackageReference does not cause that any more.

Note: before you do this, you should make a backup of your project.

Right-click on the packages.config file--> select Migrate packages.config to PackageReference

enter image description here

===============================

Update 3

Sorry for knowing that your project is a web prject, so you should add the above bindredirect on the web.config file.

[BadImageFormatException: Could not load file or assembly 'CefSharp.BrowserSubprocess.Core' or one of its dependencies. An attempt was made to load a program with an incorrect format.]

The error usually indicates that your dll version is not the same as the project version. It refers to the conflict between x64 and x86. See this similar issue.

So you should check your project very carefully.

Besides, add this in the Web.config file:

<dependentAssembly>
                    <assemblyIdentity name="Xceed.Wpf.AvalonDock" publicKeyToken="3e4669d2f30244f4" culture="neutral" />
                    <bindingRedirect oldVersion="0.0.0.0-3.8.0.0" newVersion="3.8.0.0" />
</dependentAssembly>

Add the step 2 node, and then run update-package -reinstall under Package Manager Console.

Right-click on your Webapp project Properties-->Build--> make sure that you have changed the Platfrom target to x64.

and also Check Use the 64 bit version of IIS Express for web sites and projects under Tools-->Options-->Projects and Solutions-->Web Projects

Close VS, delete bin and obj folder, restart your project.

Besides, as the official document recommends, you should install Microsoft Visual C++ 2015 Redistributable.

Also, if your PC is x64 bit and you should can use x64 platform in your project.

answered on Stack Overflow Oct 21, 2020 by Perry Qian-MSFT • edited Oct 23, 2020 by Perry Qian-MSFT

User contributions licensed under CC BY-SA 3.0