|
I have 3 components
Component A (a scheduling engine), B (a windows service) and C (a task)
Component C implements objects of type A.
Component B creates objects of type C by reflection.
Component C needs to access a SQL Server DB but i don't understand why he cannot open a connection to the DB.
This are component A permissions
using System;<br />
using System.Reflection;<br />
using System.Runtime.CompilerServices;<br />
using System.Runtime.InteropServices;<br />
using System.Security.Permissions;<br />
using System.Data.SqlClient;<br />
using System.Net.Mail;<br />
<br />
...<br />
<br />
[assembly: SmtpPermission(SecurityAction.RequestMinimum, Unrestricted = true)]<br />
[assembly: SqlClientPermission(SecurityAction.RequestMinimum, Unrestricted = true)]<br />
[assembly: UIPermission(SecurityAction.RequestMinimum, Unrestricted = false, Window = UIPermissionWindow.AllWindows)]<br />
[assembly: IsolatedStorageFilePermission(SecurityAction.RequestMinimum, UserQuota = 1048576)]<br />
[assembly: SecurityPermission(SecurityAction.RequestMinimum, UnmanagedCode = true)]<br />
[assembly: FileIOPermission(SecurityAction.RequestOptional, Unrestricted = true)]<br />
[assembly: CLSCompliant(true)]<br />
This are component B permissions
using System;<br />
using System.Reflection;<br />
using System.Runtime.CompilerServices;<br />
using System.Runtime.InteropServices;<br />
using System.Security.Permissions;<br />
using System.Diagnostics;<br />
using System.Configuration;<br />
using System.Data.SqlClient;<br />
<br />
using Microsoft.Practices.EnterpriseLibrary.Logging;<br />
<br />
...<br />
<br />
[assembly: SqlClientPermission(SecurityAction.RequestMinimum)]<br />
[assembly: ConfigurationPermission(SecurityAction.RequestMinimum, Unrestricted = true)]<br />
[assembly: EventLogPermission(SecurityAction.RequestMinimum, PermissionAccess = System.Diagnostics.EventLogPermissionAccess.Write, Unrestricted = true)]<br />
[assembly: UIPermission(SecurityAction.RequestMinimum, Clipboard = UIPermissionClipboard.AllClipboard, Unrestricted = false, Window = UIPermissionWindow.AllWindows)]<br />
[assembly: IsolatedStorageFilePermission(SecurityAction.RequestMinimum, UserQuota = 1048576)]<br />
[assembly: SecurityPermission(SecurityAction.RequestMinimum, UnmanagedCode = true)]<br />
[assembly: FileIOPermission(SecurityAction.RequestOptional, Unrestricted = true)]<br />
[assembly: CLSCompliant(true)]<br />
This are component C permissions
<br />
using System;<br />
using System.Reflection;<br />
using System.Runtime.CompilerServices;<br />
using System.Runtime.InteropServices;<br />
using System.Security.Permissions;<br />
using System.Data.SqlClient;<br />
using System.Net.Mail;<br />
<br />
...<br />
<br />
[assembly: SmtpPermission(SecurityAction.RequestMinimum, Unrestricted = true)]<br />
[assembly: SqlClientPermission(SecurityAction.RequestRefuse, Unrestricted = true)]<br />
[assembly: IsolatedStorageFilePermission(SecurityAction.RequestMinimum, UserQuota = 1048576)]<br />
[assembly: SecurityPermission(SecurityAction.RequestRefuse, UnmanagedCode = true)]<br />
[assembly: FileIOPermission(SecurityAction.RequestOptional, Unrestricted = true)]<br />
[assembly: CLSCompliant(true)]<br />
The problem is on the C component
The method which opens a Connection call stack is:
A --> B --> C
I've also tried to create a SqlClientPermission object, add the connection string and call to the Assert method but a SecurityExeption is trowed when connection.Open() method is executed.
Any Idea?
I'm on a Fuzzy State: Between 0 an 1
|
|
|
|
|
how should i insert an image in an xml file using c# without using xsl or data sets? can u plz tell me an easy way out which also consumes less memory.....and also is picture box a good idea to show the retrieved images from the same xml file or is there any other better way to show aswell?
any help would be greatly appreciated!
bia ali
-- modified at 9:00 Thursday 24th August, 2006
|
|
|
|
|
Hello
You would use an XmlReader object to read the file into an XmlDocument object, then write it back after storing whatever you want using an XmlWriter. You can find all these classes in System.Xml namespace.
About displaying the picture, a PictureBox would be appropriate. Why not??
Regards
|
|
|
|
|
Hello everybody
Is there a way to check if there is proccess open to a certain file?
I'm trying to access a file in an app I'm writing, but one of the files might be in the middle of another process (another filesteram). is there anyway to check if there is a proccess to that file?
Thanks!
|
|
|
|
|
Hello
Open it in a try block and catch any exception.
Regards
|
|
|
|
|
Hi,
You can use FileSystemWatcher on that folder. Set the notify filter and all other necessary properties. Then when the file is completed you get OnCreated and OnChanged events. Remember that these events are fired many times for the same file also, but that wont be a problem. I, myself am using the watcher. Remember the path, notifyfilters properties. Try to search how you can attach Watcher to a folder on msdn.
If any problem i can help, if u r interested in this solution.
<marquee>"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
Anant Y. Kulkarni
|
|
|
|
|
Thanks!
I'll try that.
|
|
|
|
|
Can someone tell me why I have no data showing in any of the rows on the datagrid's ComboBoxColumn I created. The Datagrid works fine and in the debugger I see all the items listed in my ComboBoxColumn cells but visually when I click the down arrow in each cell there is nothing showing up.
foreach (DataRelation relation in complexObject.Relations)
{
DataGridViewComboBoxColumn comboColumn = new DataGridViewComboBoxColumn();
comboColumn.Name = (string)relation.ExtendedProperties["ColumnName"];
dataGrid.Columns.Add(comboColumn);
foreach (DataRow row in relation.ParentTable.Rows)
{
DataRow[] childRows = row.GetChildRows(relation);
DataGridViewComboBoxCell newCell = new DataGridViewComboBoxCell();
foreach (DataRow childRow in childRows)
{
newCell.Items.Add(childRow.ItemArray[relation.ChildTable.Columns.IndexOf((string)relation.ExtendedProperties["ShowColumn"])]);
}
dataGrid.Rows[relation.ParentTable.Rows.IndexOf(row)].Cells[(string)relation.ExtendedProperties["ColumnName"]] = newCell;
}
}
|
|
|
|
|
hi,
how can i query an excel sheet to get a column values using c#.
thanks
|
|
|
|
|
What have you tried up to now?
Regards
Malc
*********************************************
|
|
|
|
|
my idea is to use a dataset and bind the excel sheet to it. but i am not sure about the provider or the connection strings.
Is it possible to achieve this with out using provider, i mean just like opening a file and querying.
|
|
|
|
|
i want to display the control of a webpage in a tree structure with the help of reflection in csharp in visual studio 2005 .....pls send a demo code..
|
|
|
|
|
Prodyut Pakhira wrote: pls send a demo code..
ROTFL.
No, we probably won't. It's rare for the plethora of 'I don't want to do anything, please do my work for me' posts to get a positive reply. Why don't you do your own job and post a question when you get stuck ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
By,
I want to know the lenght of audio file(like mp3 or Wav) in seconds.
What is the right way?
In the image file(like Jpg or Gif) i have used metadata with PropertyItem, there is a way like this?
Thanks.
|
|
|
|
|
Through DirectShow or WMP you can load an audio file and get it's length.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Excuseme,
It is possible to have an example?......an istance of the object and the dll to use.
Thanks.
|
|
|
|
|
I have the framework 1.1 and i can not know this data, you can help me please?
|
|
|
|
|
WAV files follow the RIFF standard that has a field that contains the length of data.
WAV files' headers has 3 chunks of data; RIFF chunk, FORMAT chunk and DATA chunk.
RIFF chunk: 12 bytes.
FORMAT chunk: 24 Bytes.
The DATA chunk format is as follows:
Bytes 0 - 3: 'data'
Bytes 4 - 7: Length of data.
You need length of data, sampling rate and number of bits per sample to get the duration
Extract Length of data from DATA chunk, and all other fields from the FORMAT chunk.
And done
لا إله إلا الله
|
|
|
|
|
How to populate the Bound the Treeview data into the datagrid.
Send me the sample for that
|
|
|
|
|
Sure, no problem. Whilst I am doing all your work for you, if you can think of anything else you might need, please let us know.
Regards
Malc
*********************************************
|
|
|
|
|
Is there any way to unsubscribe all event listeners for a certain event?
public delegate void myHandler(object Sender);
public event myHandler somethingChanged;
private void onSomethingChanged()
{
if(somethingChanged != null) somethingChanged(this);
}
What I would like to do is something like somethingChanged = null . Why isn't this allowed if I can actually check somethingChanged for null? somethingChanged -= someFunction is not an option, what I want is somethingChanged -= allListeners .
Can anyone help me out here?
|
|
|
|
|
Hi,
I don't know how to exactly do this but there should be a way.
I want to ask why do you want to do this ? because as far as I know your host doesn't know anything about its listeners.It's the responsibility of a listener to register or unregister itself.
Anyway how about having a flag variable that if set,it will stop the service.
For example:
<br />
public viod Stop()<br />
{<br />
stopped=true;<br />
}<br />
<br />
private void OnSomethingChanged()<br />
{<br />
if (stopped) return;<br />
}
|
|
|
|
|
Thx for the answer, wasn't expecting anyone to reply anymore. I've thought about that solution too, but I think there should be a more elegant way to fix the issue.
The reason I want to do this: the class concerned here contains some data that's shown and can be modified in dozens of places in my application. I've created a sort of "undo" function that saves a copy of the object to memory so that the user can "rollback" on his actions. These copies should contain only data, and shoudn't even try to fire any events. While debugging I found out that some references were left to my cloned objects, meaning the data in these clones is getting modified just as my "foreground" data. What's more, the number of cloned objects in memory could eventually be many thousands, so the performance hit for even for simply checking a flag each time isn't something I want.
Since manually disconnecting my eventlisteners is so sensitive to my own errors (code intensive) I'd like to be sure all eventlisteners get disconnected from the event. I'd expect the event itself to contain a list of references to all listeners. As I said before: How else could you check an event for null .
Suggestions are still welcome of course
|
|
|
|
|
Hi
This case can be an example of memento design pattern.Using this pattern you can save state of your objects in another object(a memento) and then you can put you object back to its initial state.
for example:
<br />
public class Test<br />
{<br />
private int x;<br />
public EventHandler XChanged;<br />
<br />
public int X<br />
{<br />
get{return x;}<br />
set<br />
{<br />
this.x=value;<br />
if(this.XChanged!=null) XChanged(this,EventArgs.Empty);<br />
}<br />
<br />
public TestMemento GetMemento()<br />
{<br />
TestMemento memento=new TestMemento();<br />
memento.AddField("x",this.x");<br />
}<br />
<br />
public void SetMemento(TestMemento memento)<br />
{<br />
this.x=(int)memento.GetField("x");<br />
}<br />
<br />
}<br />
and here is TestMemento
<br />
public class TestMemento<br />
{<br />
public void AddField(string key,object value)<br />
{<br />
this.fieldsMap.Add(key,value);
}<br />
public object GetField(string key)<br />
{<br />
return this.fieldsMap[key];<br />
}<br />
}<br />
this way you can save an object state and load it again.
Take a look at serialization patterns in C# and .Net framework.
Regards
|
|
|
|
|
Hi,
Thanks for the suggestion, someone has offered me the memento pattern before, and next time I'm implementing a feature like this I'll be sure to use it. Unfortunately I found out a bit late about this in order to use it for the current project: Should I want to convert my project to use this pattern would mean I'd have to change about 1500 base datatypes to start using it, I'm afraid I don't have the time or spirit to do so.
For now I found an ugly hack around the problem: I serialize the class and store it to a memorystream, then inmedialtely deserialize it and add it to my Collection of "undo" objects. Since the event is marked as non-serializable it gets initialized to null as soon as I deserialize it. It's a bit ugly and I still don't see why I can't just set event myEvent = null . But this performs quite well actually.
Cheers and thanks for the help!
-- modified at 10:10 Friday 25th August, 2006
|
|
|
|