首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >VisualStudio2019配置已编译的.dll程序集不存在

VisualStudio2019配置已编译的.dll程序集不存在
EN

Stack Overflow用户
提问于 2020-10-20 15:54:58
回答 1查看 1.4K关注 0票数 0

我正在Visual Studio 2019中运行一个项目,在这里我使用CefSharp包,它要求我将调试/发布配置模式设置为x64

当我运行我的项目时,我会收到一个错误,它无法初始化,因为:

"C:\myProject\Work\Code\myProject..\myProject.dll“不存在。

我的项目文件夹是:

代码语言:javascript
运行
复制
C:\myProject\Work\Code\myProject\myProject

我已经将模式设置为Debugx64,并将Output path设置为x64\,这意味着它指向:

代码语言:javascript
运行
复制
C:\myProject\Work\Code\myProject\myProject\x64

当我检查上面提到的两个文件夹位置的文件夹内容时,它们都包含一个"myProject.dll“文件。

但错误仍然存在..。即使我将完整的路径放置在Output path中,而不仅仅是x64\中,它仍然不起作用。

我想知道什么可能是错误的,因为即使.dll不是“正确的”,它仍然会找到它。

谢谢

编辑:

我已经尝试了first solution 中提出的解决方案。我检查了.csproj文件,删除了bin/obj/.vs文件夹,并尝试了链接建议中的内容。

当我重新启动VS时,默认情况下是在AnyCPU上。如果我这样构建它,它编译时不会出错,但是当我运行应用程序时,它会失败并给出错误:

FileNotFoundException:无法加载文件或程序集“CefSharp.Wpf、Version=84.4.10.0、Culture=neutral、PublicKeyToken=40c4b6fc221f4138”或其依赖项之一。系统找不到指定的文件。

如果不是以AnyCPU的形式构建和运行,而是尝试切换到x64,那么我会得到一个编译错误:

没有为项目‘BIMbase.csproj设置OutputPath属性。请检查以确保您已为此项目指定了有效的配置和平台组合。配置=‘Debug’Platform='x64‘。如果其他项目试图遵循对此项目的项目对项目的引用,该项目已卸载或未包含在解决方案中,并且引用项目没有使用相同或等效的配置或平台,则也可能出现此错误。

根据请求 .csproj:

代码语言:javascript
运行
复制
<?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>

因此,我认为CefSharp包可能有问题,但我不知道它如何或是否有助于“恢复”它,它在AnyCPU中似乎编译得很好,但是在应该正确运行的x64中,它不能编译。

编辑:

嗨,谢谢你的帮助。我在您的Update中尝试了和2)。它没有起作用。在尝试3)之前,我想再添加几个注释,也许这将有助于理解这个问题。

注意:我已经完全删除了我可以在任何地方找到的任何CefSharp跟踪。

当运行Webapp时,它可以在LocalHost上找到。在使用客户端代码运行实际应用程序时,我会得到以下全部错误:

代码语言:javascript
运行
复制
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

此外,当我重新构建我的项目时,我有一些错误/警告,我认为其中一些与您提到的步骤有关:

C:\BIMbase\Work\Code\BIMbase\packages\Extended.Wpf.Toolkit.3.8.1\lib\net40\Xceed.Wpf.AvalonDock.dll将程序集"Xceed.Wpf.AvalonDock,Culture=neutral,PublicKeyToken=3e4669d2f30244f4“从版本"2.0.19.10”C:\Program \Autodesk\Revit2020\Xceed.Wpf.AvalonDock.dll重新映射到版本"3.8.0.0“,以解决冲突并消除警告。 MicrosoftVisualStudio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2084,5):警告1>C:\Program文件(X86):发现同一依赖程序集的不同版本之间的冲突。请在项目文件中将"AutoGenerateBindingRedirects“属性设置为true。有关更多信息,请参见http://go.microsoft.com/fwlink/?LinkId=294190

上面的第二个错误指的是代码:

代码语言:javascript
运行
复制
 false    true  

不知道为什么CefSharp错误仍然存在..。

EN

回答 1

Stack Overflow用户

发布于 2020-10-21 03:05:20

如果在配置中添加x64,则应该使用试着按照这个答案所描述的步骤

建议

之后,,您应该检查您的myProject.csproj文件,并确保您已经为x64模式定义了正确的outputpath

添加这样的

代码语言:javascript
运行
复制
<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>

它将使outputpath of configuration x64

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

除了之外,检查文件并确保属性没有其他configuration x64条件导致与其冲突。记住只保留像上面一样的一个。

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

如果您已经完成了所有步骤,则可以尝试以下步骤:

1)关闭VS,删除解决方案文件夹C:\myProject\Work\Code\myProject下的.vs隐藏文件夹。

还有binobj文件夹下的项目文件夹,任何x64文件夹都要创建一个干净的构建环境。

2)重新启动项目以重新构建以测试它。

此外,,如果这些不起作用,我建议您可以与我们共享您的myProject.csproj文件,以帮助我们更快地解决问题。

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

更新1

实际上是,您应该根据CefSharp nuget包的要求在X64X86下构建和运行您的项目。您不应该在AnyCPU下构建您的项目,因为nuget包CefSharp.Common需要x64x86

您应该在Build-->Configuration Manager下更改平台,如下所示:

(1)除了Configuration,,您还应该与其他 Platform定义一起定义Debug|x64属性:

代码语言:javascript
运行
复制
..............

<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>

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

Tools-->Nuget Package Manager-->Package Manager Conosole下的运行update-package -reinstall

当您构建项目时,尝试像这样在Build-->Configuration Manager下进行配置。

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

更新2

解决办法是添加bindredirect

下面的有三种方法,您可以尝试其中之一:

溶液

1)右键单击project-->Add-->New项->选择应用程序配置文件文件模板->并将其命名为App.config

在该文件中添加以下内容:

代码语言:javascript
运行
复制
<?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)或在BIMbase.csproj文件下添加这些BIMbase.csproj节点:

代码语言:javascript
运行
复制
<PropertyGroup>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>

3)如果不能工作,可以将packages.config nuget管理格式更改为PackageReference nuget管理格式。这个问题总是发生在PackageReference上,而packages.config不会再造成这种情况。

注意事项:在进行此操作之前,您应该对项目进行备份。

右键单击packages.config文件->选择Migrate packages.config to PackageReference

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

更新3

很抱歉知道您的项目是一个web项目,所以您应该在web.config文件中添加上面的bindredirect。

BadImageFormatException:无法加载文件或程序集“CefSharp.BrowserSubprocess.Core”或其依赖项之一。试图加载格式不正确的程序。

此错误通常表示dll版本与项目版本不相同。它指的是x64x86之间的冲突。见这个类似的问题

所以你应该非常仔细地检查你的项目。

除了之外,将其添加到Web.config文件中:

代码语言:javascript
运行
复制
<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>

添加--步骤2节点,然后在Package Manager Console下运行update-package -reinstall

Right-click on您的Webapp项目Properties-->Build-->确保您已经将Platfrom target更改为x64

Tools-->Options-->Projects和Solutions-->Web项目中的和也检查Use the 64 bit version of IIS Express for web sites and projects

关闭VS,删除binobj文件夹,重新启动项目。

除了,正如正式文件所建议的那样,您应该安装Microsoft Visual C++ 2015可再发行版

也是,如果你的PC是x64位,你可以在你的项目中使用x64平台。

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

https://stackoverflow.com/questions/64448875

复制
相关文章

相似问题

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