You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

新建Xamarin.Forms项目抛出System.Exception,无法正常创建ContentPage

Hey there, sorry to hear you're stuck with this frustrating Xamarin.Forms ContentPage creation issue in Visual Studio 2017 Community. Let's walk through some proven fixes that should help resolve the problem:

Fixes for Xamarin.Forms ContentPage Creation Failures in VS2017 Community

1. Clear Visual Studio's Cache

Corrupted cache files are a common culprit for weird project system glitches. Here's how to wipe them:

  • Close all instances of Visual Studio
  • Delete these folders (replace 15.0_* with your specific VS2017 folder name):
    • %LOCALAPPDATA%\Microsoft\VisualStudio\15.0_*\ComponentModelCache
    • %LOCALAPPDATA%\Microsoft\VisualStudio\15.0_*\Temp
  • Restart VS and try creating a ContentPage again

2. Manually Fix Project File References

Since you mentioned the new Page files are now being recognized, let's ensure their references in the .csproj file are configured correctly:

  • Right-click your project → Unload Project
  • Right-click the unloaded project → Edit [YourProjectName].csproj
  • Look for the entries related to your new Page, and make sure they match this format:
<ItemGroup>
  <Compile Include="Page2.xaml.cs">
    <DependentUpon>Page2.xaml</DependentUpon>
  </Compile>
  <EmbeddedResource Include="Page2.xaml">
    <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
    <SubType>Designer</SubType>
  </EmbeddedResource>
</ItemGroup>
  • Save the file, reload the project, and check if the files show up properly in Solution Explorer

3. Update Visual Studio 2017 to the Latest Version

Microsoft released multiple updates for VS2017 that fixed tons of Xamarin-related bugs. Do this:

  • Open the Visual Studio Installer
  • Click the Update button to install all available updates for VS2017
  • Restart VS after the update completes and test the ContentPage creation

4. Reset Visual Studio Settings

Misconfigured settings can cause unexpected behavior. Let's reset them to default:

  • Open VS → Tools → Import and Export Settings → Reset All Settings
  • Select "No, just reset settings, overwriting my current settings" and choose the default settings collection
  • Restart VS and try creating a ContentPage again

5. Update Xamarin.Forms NuGet Package

Outdated NuGet packages can lead to compatibility issues:

  • Right-click your solution → Manage NuGet Packages for Solution
  • Find Xamarin.Forms and update it to the latest stable version
  • Clean your solution (Build → Clean Solution) then rebuild it

If none of these fixes work, try creating a brand new Xamarin.Forms project and test creating a ContentPage there. This will help you figure out if the issue is specific to your existing project or a broader VS/Xamarin problem.

内容的提问来源于stack exchange,提问作者AdrianK09

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:44:46