Windows Phone 8应用程序不包含InitializeComponent的定义。

时间:2022-04-29 16:56:42

I have just downloaded the 14 CTP version of Visual Studio and created a blank app for Windows Phone. I tried to open the MainPage.xaml and the designer shows up the following errors:

我刚刚下载了14个CTP版本的Visual Studio,并为Windows Phone创建了一个空白应用程序。我试着打开主页。xaml和设计器出现以下错误:

Windows Phone 8应用程序不包含InitializeComponent的定义。

and for those who can't see the image:

对于那些看不到图像的人:

System.Exception
Package failed updates, dependency or conflict validation.

Windows cannot install package App.a5cd6ef3c.a895b.a4508.a96fd.af1634c30bb13 because this package depends on another package that could not be found. This package requires minimum version 0.0.0.0 of framework Microsoft.VCLibs.140.00.Debug published by any publisher to install. Provide the framework along with this package.
   at Microsoft.Expression.HostUtility.Platform.AppContainerProcessDomainFactory.CreateDesignerProcess(String applicationPath, String clientPort, Uri hostUri, IDictionary environmentVariables, Int32& processId, Object& processData)
   at Microsoft.Expression.DesignHost.Isolation.Primitives.ProcessDomainFactory.ProcessIsolationDomain..ctor(ProcessDomainFactory factory, IIsolationBoundary boundary, AppDomainSetup appDomainInfo, FrameworkName targetFramework, String identifier, String baseDirectory)
   at Microsoft.Expression.DesignHost.Isolation.Primitives.ProcessDomainFactory.CreateIsolationDomain(IIsolationBoundary boundary)
   at Microsoft.Expression.HostUtility.Platform.AppContainerProcessDomainFactory.CreateIsolationDomain(IIsolationBoundary boundary)
   at Microsoft.Expression.DesignHost.Isolation.Primitives.IsolationBoundary.Initialize()
   at Microsoft.Expression.DesignHost.Isolation.Primitives.IsolationBoundary.CreateInstance[T](Type type)
   at Microsoft.Expression.DesignHost.Isolation.IsolatedObjectFactory.Initialize()
   at Microsoft.VisualStudio.ExpressionHost.Services.VSIsolationService.CreateObjectFactory(IIsolationTarget isolationTarget, IObjectCatalog catalog)
   at Microsoft.Expression.DesignHost.Isolation.IsolationService.CreateLease(IIsolationTarget isolationTarget)
   at Microsoft.Expression.DesignHost.Isolation.IsolationService.CreateLease(IIsolationTarget isolationTarget)
   at Microsoft.Expression.DesignHost.Isolation.IsolationService.CreateLease(IIsolationTarget isolationTarget)
   at Microsoft.Expression.DesignHost.IsolatedDesignerService.CreateLease(IIsolationTarget isolationTarget, CancellationToken cancelToken, DesignerServiceEntry& entry)
   at Microsoft.Expression.DesignHost.IsolatedDesignerService.IsolatedDesignerView.CreateDesignerViewInfo(CancellationToken cancelToken)
   at Microsoft.Expression.DesignHost.Isolation.IsolatedTaskScheduler.InvokeWithCulture[T](CultureInfo culture, Func`2 func, CancellationToken cancelToken)
   at Microsoft.Expression.DesignHost.Isolation.IsolatedTaskScheduler.<>c__DisplayClass5`1.<StartTask>b__7()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()

I entered App1.xaml.cs and MainPage.xaml.cs and I've seen that App and MainPage, respectively, don't have a definition for InitializeComponent().

我进入App1.xaml。cs和MainPage.xaml。cs和我已经分别看到了应用程序和MainPage,对于InitializeComponent()没有定义。

The project is in the state it was created by Visual Studio, I haven't changed anything!

这个项目是由Visual Studio创建的,我什么都没变!

Why is this happening and how can I solve it?

为什么会发生这种情况,我怎么解决呢?

6 个解决方案

#1


5  

the same started to happen to me today; to reproduce the issue, I just open Visual Studio 2013 Update 4, create a blank Windows Phone 8.1 and double click on MainPage.xaml.

同样的事情今天也发生在我身上;为了重现这个问题,我只打开Visual Studio 2013更新4,创建一个空白的Windows Phone 8.1,并双击MainPage.xaml。

I solved by performing the following (a mix of what I've read around the web):

我解决了以下问题(我在网上看到的内容):

  • exit all Visual Studio instances
  • 退出所有Visual Studio实例。
  • delete everything on %localappdata%\Microsoft\VisualStudio\12.0\Designer\ShadowCache
  • 删除所有微软% localappdata % \ \ VisualStudio \ 12.0 \设计\ ShadowCache
  • open a command prompt with admin rights and execute the following commands:

    使用管理员权限打开命令提示符并执行以下命令:

    pushd %VS110COMNTOOLS%
    icacls ..\IDE /grant *S-1-15-2-1:(OI)(F)
    icacls ..\IDE /grant *S-1-15-2-1:(CI)(F)
    icacls ..\IDE\PrivateAssemblies /grant *S-1-15-2-1:(OI)(F)
    icacls ..\IDE\PrivateAssemblies /grant *S-1-15-2-1:(CI)(F)
    icacls ..\IDE\PublicAssemblies /grant *S-1-15-2-1:(OI)(F)
    icacls ..\IDE\PublicAssemblies /grant *S-1-15-2-1:(CI)(F)
    

finally, reboot. worked on Windows 8.1 64-bit.

最后,重启。在Windows 8.1 64位上工作。

#2


5  

Ensure the class name on your XAML matches the class name in your code-behind. I've run into this a few times while refactoring.

确保XAML上的类名与代码后面的类名匹配。在重构的过程中,我遇到过几次这样的情况。

XAML Opening Tag:

XAML开始标记:

<UserControl
    x:Class="Namespace.Foo"
    ... />

Code Behind:

背后的代码:

public sealed partial class Bar : UserControl
{
    public Bar()
    {
        // This will become the error specified (does not contain definition)
        this.InitializeComponent(); 
    }
    ...
}

So Namespace.Foo would need to be Namespace.Bar here to get rid of the error. This should have the same behavior if using Page instead of UserControl.

所以名称空间。Foo需要命名空间。在这里可以去掉这个错误。如果使用页面而不是用户控件,则应该具有相同的行为。

#3


1  

Check your x:class property in your page

在页面中检查x:class属性。

#4


0  

  1. “tools”——>"extensions and updates"——>install or update "nuget package manager" and something like that ;
  2. “工具”——>“扩展和更新”——>安装或更新“nuget软件包管理器”之类的东西;
  3. try to open as administrator
  4. 尝试以管理员身份打开。
  5. it seems like disk in fat32 will lead to the error
  6. 看起来fat32中的磁盘会导致错误。
  7. if u install Silvertlight before the SDK ,it may lead to the error
  8. 如果在SDK之前安装Silvertlight,可能会导致错误。

#5


0  

Ran into same problem today, Fixed it by killing all instances and opening it up again.

今天遇到了同样的问题,通过杀死所有实例并再次打开它来修复它。

#6


0  

It does not work for me. Just created new local account with Administrator type (Window 8.1, VS 2013 update 4). Login by the new local account. Open and see it is solved.

它对我不起作用。刚刚创建了新的本地帐户与管理员类型(Window 8.1, VS 2013更新4)。登录到新的本地帐户。打开并看到它被解决了。

#1


5  

the same started to happen to me today; to reproduce the issue, I just open Visual Studio 2013 Update 4, create a blank Windows Phone 8.1 and double click on MainPage.xaml.

同样的事情今天也发生在我身上;为了重现这个问题,我只打开Visual Studio 2013更新4,创建一个空白的Windows Phone 8.1,并双击MainPage.xaml。

I solved by performing the following (a mix of what I've read around the web):

我解决了以下问题(我在网上看到的内容):

  • exit all Visual Studio instances
  • 退出所有Visual Studio实例。
  • delete everything on %localappdata%\Microsoft\VisualStudio\12.0\Designer\ShadowCache
  • 删除所有微软% localappdata % \ \ VisualStudio \ 12.0 \设计\ ShadowCache
  • open a command prompt with admin rights and execute the following commands:

    使用管理员权限打开命令提示符并执行以下命令:

    pushd %VS110COMNTOOLS%
    icacls ..\IDE /grant *S-1-15-2-1:(OI)(F)
    icacls ..\IDE /grant *S-1-15-2-1:(CI)(F)
    icacls ..\IDE\PrivateAssemblies /grant *S-1-15-2-1:(OI)(F)
    icacls ..\IDE\PrivateAssemblies /grant *S-1-15-2-1:(CI)(F)
    icacls ..\IDE\PublicAssemblies /grant *S-1-15-2-1:(OI)(F)
    icacls ..\IDE\PublicAssemblies /grant *S-1-15-2-1:(CI)(F)
    

finally, reboot. worked on Windows 8.1 64-bit.

最后,重启。在Windows 8.1 64位上工作。

#2


5  

Ensure the class name on your XAML matches the class name in your code-behind. I've run into this a few times while refactoring.

确保XAML上的类名与代码后面的类名匹配。在重构的过程中,我遇到过几次这样的情况。

XAML Opening Tag:

XAML开始标记:

<UserControl
    x:Class="Namespace.Foo"
    ... />

Code Behind:

背后的代码:

public sealed partial class Bar : UserControl
{
    public Bar()
    {
        // This will become the error specified (does not contain definition)
        this.InitializeComponent(); 
    }
    ...
}

So Namespace.Foo would need to be Namespace.Bar here to get rid of the error. This should have the same behavior if using Page instead of UserControl.

所以名称空间。Foo需要命名空间。在这里可以去掉这个错误。如果使用页面而不是用户控件,则应该具有相同的行为。

#3


1  

Check your x:class property in your page

在页面中检查x:class属性。

#4


0  

  1. “tools”——>"extensions and updates"——>install or update "nuget package manager" and something like that ;
  2. “工具”——>“扩展和更新”——>安装或更新“nuget软件包管理器”之类的东西;
  3. try to open as administrator
  4. 尝试以管理员身份打开。
  5. it seems like disk in fat32 will lead to the error
  6. 看起来fat32中的磁盘会导致错误。
  7. if u install Silvertlight before the SDK ,it may lead to the error
  8. 如果在SDK之前安装Silvertlight,可能会导致错误。

#5


0  

Ran into same problem today, Fixed it by killing all instances and opening it up again.

今天遇到了同样的问题,通过杀死所有实例并再次打开它来修复它。

#6


0  

It does not work for me. Just created new local account with Administrator type (Window 8.1, VS 2013 update 4). Login by the new local account. Open and see it is solved.

它对我不起作用。刚刚创建了新的本地帐户与管理员类型(Window 8.1, VS 2013更新4)。登录到新的本地帐户。打开并看到它被解决了。