ユーザーコントロールを作成しました。このコントロールは、静的な Entity Framework クラスも利用して 2 つのコンボボックスを読み込みます。すべてが順調で、問題なく実行されます。デザインとランタイムは機能しています。次に、アプリケーションを停止すると、UserControl を含むすべてのフォームが設計時に機能しなくなります。次の 2 つのエラーが表示されます。
エラー 1: 指定された名前付き接続が構成内に見つからないか、EntityClient プロバイダーでの使用が意図されていないか、無効です。
エラー 2: 変数ccArtikelVelden
が宣言されていないか、割り当てられていません。(ccArtikelVelde は私のものですUserControl
)
ランタイムのすべてがまだ機能しています
私の静的EFリポジトリクラス:
public class BSManagerData
{
private static BSManagerEntities _entities;
public static BSManagerEntities Entities
{
get
{
if (_entities == null)
_entities = new BSManagerEntities();
return _entities;
}
set
{
_entities = value;
}
}
}
コンボボックスにデータをロードするために UserControl で発生するいくつかのロジック:
private void LaadCbx()
{
cbxCategorie.DataSource = (from c in BSManagerData.Entities.Categories
select c).ToList();
cbxCategorie.DisplayMember = "Naam";
cbxCategorie.ValueMember = "Id";
}
private void cbxCategorie_SelectedIndexChanged(object sender, EventArgs e)
{
cbxFabrikant.DataSource = from f in BSManagerData.Entities.Fabrikants
where f.Categorie.Id == ((Categorie)cbxCategorie.SelectedItem).Id
select f;
cbxFabrikant.DisplayMember = "Naam";
cbxFabrikant.ValueMember = "Id";
}
設計時にフォームを再び機能させる唯一の方法は、UserControl の EF 部分をコメントアウトして (上記を参照)、再構築することです。非常に奇妙です。すべてが同じアセンブリ、同じ名前空間にあります (簡単にするため)。
誰でもアイデアはありますか?