Hello,
I am looking for a little help with this. I have a WPF browser form that I am trying to load. I run the debugger, but when it gets to the page I get the following:
An exception of type 'System.Security.SecurityException' occurred in System.Data.dll but was not handled in user code
Additional information: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
If there is a handler for this exception, the program may be safely continued.
The call stack for that shows this:
> HomeInventoryWebForms.exe!HomeInventoryWebForms.frmMoviesAdd.dgMTVAddFormat_Window_Loaded(object sender, System.Windows.RoutedEventArgs e) Line 70 C#
So here is the code behind the form:
public frmMoviesAdd()
{
InitializeComponent();
this.Loaded += dgMTVAddFormat_Window_Loaded;
this.Loaded += dgMTVAddGenre_Window_Loaded;
}
private void dgMTVAddFormat_Window_Loaded(object sender, RoutedEventArgs e)
{
FormatDataClassesDataContext data = new FormatDataClassesDataContext();
List<tblFormat> Format = (from FormatName in data.tblFormats select FormatName).ToList();
dgMTVAddFormat.ItemsSource = Format;
}
This is backed up with LINQ to SQL class that was auto generated:
[global::System.Data.Linq.Mapping.DatabaseAttribute(Name="HomeInventory")]
public partial class FormatDataClassesDataContext : System.Data.Linq.DataContext
{
private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
#region Extensibility Method Definitions
partial void OnCreated();
partial void InserttblFormat(tblFormat instance);
partial void UpdatetblFormat(tblFormat instance);
partial void DeletetblFormat(tblFormat instance);
#endregion
public FormatDataClassesDataContext() :
base(global::HomeInventoryWebForms.Properties.Settings.Default.HomeInventoryConnectionString, mappingSource)
{
OnCreated();
}
public FormatDataClassesDataContext(string connection) :
base(connection, mappingSource)
{
OnCreated();
}
public FormatDataClassesDataContext(System.Data.IDbConnection connection) :
base(connection, mappingSource)
{
OnCreated();
}
public FormatDataClassesDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
public FormatDataClassesDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
public System.Data.Linq.Table<tblFormat> tblFormats
{
get
{
return this.GetTable<tblFormat>();
}
}
}
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.tblFormat")]
public partial class tblFormat : INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
private int _FormatID;
private string _FormatName;
#region Extensibility Method Definitions
partial void OnLoaded();
partial void OnValidate(System.Data.Linq.ChangeAction action);
partial void OnCreated();
partial void OnFormatIDChanging(int value);
partial void OnFormatIDChanged();
partial void OnFormatNameChanging(string value);
partial void OnFormatNameChanged();
#endregion
public tblFormat()
{
OnCreated();
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_FormatID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
public int FormatID
{
get
{
return this._FormatID;
}
set
{
if ((this._FormatID != value))
{
this.OnFormatIDChanging(value);
this.SendPropertyChanging();
this._FormatID = value;
this.SendPropertyChanged("FormatID");
this.OnFormatIDChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_FormatName", DbType="VarChar(MAX) NOT NULL", CanBeNull=false)]
public string FormatName
{
get
{
return this._FormatName;
}
set
{
if ((this._FormatName != value))
{
this.OnFormatNameChanging(value);
this.SendPropertyChanging();
this._FormatName = value;
this.SendPropertyChanged("FormatName");
this.OnFormatNameChanged();
}
}
}
public event PropertyChangingEventHandler PropertyChanging;
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void SendPropertyChanging()
{
if ((this.PropertyChanging != null))
{
this.PropertyChanging(this, emptyChangingEventArgs);
}
}
protected virtual void SendPropertyChanged(String propertyName)
{
if ((this.PropertyChanged != null))
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
#pragma warning restore 1591
Now I am trying to bind this all to a checked box datagrid in the WPF with code that looks like this:
<Label x:Name="lblMTVAddFormat" Style="{StaticResource Label Style}" Content="Formats" Margin="335,74,0,0" Width="97"/><DataGrid x:Name="dgMTVAddFormat" Margin="437,74,10,265" AutoGenerateColumns="False"><DataGrid.Columns><DataGridCheckBoxColumn Binding="{Binding fBool}" /><DataGridTextColumn Binding="{Binding Path='FormatName'}" /></DataGrid.Columns></DataGrid>
This is all running from a local disk, connected to a remote developer database. I have no build errors or anything when I go to the debug, hitting continue sends it to another break for the exact same reason. Which loops out of the program and
shuts down the debugger. Could anyone point me in the direction to go since it is throwing this error on debug?
Michael R. Mastro II