无法使用Code First部署WPF应用程序。 [英] Trouble Deploying WPF app with Code First.

查看:82
本文介绍了无法使用Code First部署WPF应用程序。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个wpf应用程序ctp5,代码优先,.net 4,win7 sp1。

This is a wpf app ctp5, code first, .net 4, win7 sp1.

我在使用sql ce db部署这个简单的wpf应用程序时遇到错误 部署没有数据库的应用程序可以正常工作。 我有一个未处理的异常处理程序,但它没有被调用。

I am getting an error when deploying this simple wpf app using a sql ce db.  Deploying an app without a db works fine.  I have an unhandled exception handler but it is not invoked.

这是app.xaml.cs的构造函数

Here is the constructor for the app.xaml.cs

public App()
{
App.vm = new ViewModel();
}

以下是ViewMdodel的代码

Here is the code for the ViewMdodel

public class ViewModel
{
public PhotoTaggerDB db = new PhotoTaggerDB();
public ObservableCollection<Tag> Tags { getset; }
public ObservableCollection<UserFile> UserFiles { getset; }
public ObservableCollection<Tag> CurrentFileTags { getset; }
public ObservableCollection<Tag> CurrentFileTags2 { getset; }
public Collection<Tag> DeletedTags { getset; }

public UserFile SelectedUserFile { getset; }

public ViewModel()
{
this.InitializeModel();
}

private void InitializeModel()
{
this.Tags = new ObservableCollection<Tag>();
this.UserFiles = new ObservableCollection<UserFile>();
this.CurrentFileTags = new ObservableCollection<Tag>();
this.CurrentFileTags2 = new ObservableCollection<Tag>();
this.PopulateTagsCol();
this.PopulateUserFilesCol();
if(this.UserFiles.Count > 0)
this.SelectUserFile(1);
}

public void PopulateTagsCol()
{
if (this.Tags != null)
this.Tags.Clear();

//this is where it crashes.
foreach (Tag t in db.Tags)
this.Tags.Add(t);
}

这是错误消息。

应用程序:PhotoTagger.exe

框架版本:v4.0.30319

描述:该过程由于未处理的例外。

异常信息:System.ArgumentException

Stack:

  在System.Data.Common.DbProviderFactories.GetFactory(System.String)

  在System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(System.String)

  在System.Data.Entity.Internal.LazyInternalConnection.Initialize()

  在System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel()

  在System.Data.Entity.Internal.LazyInternalContext.InitializeContext()

  在System.Data.Entity.Internal.InternalContext.Initialize()

   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(System.Type)

  在System.Data.Entity.Internal.Linq.InternalSet`1 [[System .__ Canon,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089]]。初始化()

  ;&NBSP;在System.Data.Entity.Internal.Linq.InternalSet`1 [[System .__ Canon,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089]]。GetEnumerator()

  ;&NBSP;在System.Data.Entity.Infrastructure.DbQuery`1 [[System .__ Canon,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089]]。System.Collections.Generic.IEnumerable< TResult> .GetEnumerator()

  在PhotoTagger.Data.ViewModel.PopulateTagsCol()

  在PhotoTagger.Data.ViewModel.InitializeModel()

  在PhotoTagger.Data.ViewModel..ctor()

  在PhotoTagger.App..ctor()

  在PhotoTagger.App.Main()

Application: PhotoTagger.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentException
Stack:
   at System.Data.Common.DbProviderFactories.GetFactory(System.String)
   at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(System.String)
   at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
   at System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel()
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.InternalContext.Initialize()
   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(System.Type)
   at System.Data.Entity.Internal.Linq.InternalSet`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Initialize()
   at System.Data.Entity.Internal.Linq.InternalSet`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].GetEnumerator()
   at System.Data.Entity.Infrastructure.DbQuery`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].System.Collections.Generic.IEnumerable<TResult>.GetEnumerator()
   at PhotoTagger.Data.ViewModel.PopulateTagsCol()
   at PhotoTagger.Data.ViewModel.InitializeModel()
   at PhotoTagger.Data.ViewModel..ctor()
   at PhotoTagger.App..ctor()
   at PhotoTagger.App.Main()



*********************** *******************


******************************************

应用程序:PhotoTagger.exe Framework版本:v4.0.30319描述:该进程因终止而终止未处理的异常。异常信息:System.ArgumentException Stack:位于System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(System.String)的System.Data.Common.DbProviderFactories.GetFactory(System.String)处于System.Data.Entity的
位于System.Data.Entity.Internal的文件中的System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel()处于System.Data.Entity.Internal的文件中,System.Data.Eitity.Initialize( System.Data.Entity.Internal.Linq.InternalSet`1 [[System .__ Canon,mscorlib,Version = 4.0.0.0,Culture:System.Data.Entity.InternalContext.GetEntitySetAndBaseTypeForType(System.Type)
System.Data.Entity.Internal.Linq.InternalSet`1 [[System .__ Canon,
mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = System.Data.Entity.Infrastructure.DbQuery`1 [[System .__ Canon,mscorlib,Version = 4]中的GetEnumerator()[b77a5c561934e089]]。 .0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089]]。System.Collections.Generic.IEnumerable< TResult> .GetEnumerator()
在PhotoTagger.Data.DataModel.PopulateTagsCol()的PhotoTagger.Data.ViewModel。 PhotoTagger.App.Main上的PhotoTagger.Data.ViewModel..ctor()中的InitializeModel()

Application: PhotoTagger.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.ArgumentException Stack: at System.Data.Common.DbProviderFactories.GetFactory(System.String) at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(System.String) at System.Data.Entity.Internal.LazyInternalConnection.Initialize() at System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel() at System.Data.Entity.Internal.LazyInternalContext.InitializeContext() at System.Data.Entity.Internal.InternalContext.Initialize() at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(System.Type) at System.Data.Entity.Internal.Linq.InternalSet`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Initialize() at System.Data.Entity.Internal.Linq.InternalSet`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].GetEnumerator() at System.Data.Entity.Infrastructure.DbQuery`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].System.Collections.Generic.IEnumerable<TResult>.GetEnumerator() at PhotoTagger.Data.ViewModel.PopulateTagsCol() at PhotoTagger.Data.ViewModel.InitializeModel() at PhotoTagger.Data.ViewModel..ctor() at PhotoTagger.App..ctor() at PhotoTagger.App.Main()

******** ******************************************

**************************************************

错误应用程序名称:PhotoTagger.exe,版本:1.0.0.0,时间戳:0x4d82d648

错误模块名称:KERNELBASE.dll,版本:6.1.7601.17514,时间戳:0x4ce7bafa

异常代码:0xe0434352

故障偏移:0x0000b727

故障流程ID:0x14fc

故障应用程序启动时间:0x01cbe51f8f49959e

错误的应用程序路径:C:\TPSApps \DocumentTagger \ PhotoTagger.exe

错误模块路径:C:\ Windows \ syswow64 \ KERNELBASE.dll

报告ID:d0e2d3fa-5112-11e0-8124-00270e360f4c 

Faulting application name: PhotoTagger.exe, version: 1.0.0.0, time stamp: 0x4d82d648
Faulting module name: KERNELBASE.dll, version: 6.1.7601.17514, time stamp: 0x4ce7bafa
Exception code: 0xe0434352
Fault offset: 0x0000b727
Faulting process id: 0x14fc
Faulting application start time: 0x01cbe51f8f49959e
Faulting application path: C:\TPSApps\DocumentTagger\PhotoTagger.exe
Faulting module path: C:\Windows\syswow64\KERNELBASE.dll
Report Id: d0e2d3fa-5112-11e0-8124-00270e360f4c 

推荐答案

嗨Terrence,

Hi Terrence,

听起来你可能不会你要部署的机器上安装了SQL CE吗?

Sounds like you probably don't have SQL CE installed on the machine you are deploying to?

~Rowan


这篇关于无法使用Code First部署WPF应用程序。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆