|
There is most definitely an issue when running an assembly from the intranet. Code Access Security is a major feature of the CLR and this is often overlooked. The wizard you use is junk - don't use it. Learn about code access security and use the Microsoft .NET Framework Configuration snap-in and do it the right way.
In your case, you're using a method or class that requires a certain permissiont that is not granted to assemblies running in the Intranet zone. The wizard only collections assembly evidence instead of host evidence and so, if you're using automatic versioning (using the asterisk in the AssemblyVersionAttribute , which is a very BAD idea for so many reasons I can't believe they included it as a feature), the assembly evidence won't match what the wizard collected (because the version is different). Also, assembly evidence isn't always presented to the CLR, such as in the case of smart clients (assemblies executed in Internet Explorer). Code access security is an important feature to understand to avoid these cases and, preferably, use to your advantage to customize your application in case certain permissions are granted to your assembly/assemblies.
Fortunately, there was a great article posted on CodeProject about code access security not long ago: Understanding .NET Code Access Security[^].
You can also find more information about code access security and various permissions in the .NET base class library at http://msdn.microsoft.com/library/en-us/cpguide/html/cpconcodeaccesssecurity.asp[^].
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath,
It's amazing that I just spend $1100 on CD training for .NET and I didn't hear one word about assembly security. I'll be sure to read that article that you mentioned.
It's equally amazing how cyptic of an answer I got from MS on their newsgroup.
I was able to get the Framework Configuration snap-in to work but only after I realized (after about 3 hours) that there were TWO versions to choose from on my machine. It looks like I was tweaking the one for Version 1.0. When I used the 1.1 version things started to make sense again. I made a new Code Group in Runtime Security Policy/Machine/Code Groups and made my mapped netword drive fully trusted.
You guys ever wonder why you do this stuff for a living?
Thanks
Ken Galer
Electrical Engineer
Preferred Utilities Corp.
Danbury, CT 06810
|
|
|
|
|
Just go to show that the best material you can read is the .NET Framework SDK documentation - and it's free! I learned pretty much everything I know from that in the old 1.0 bata days and everything else is based on experience from that initial reading and checking out interesting code samples on sites like CodeProject.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
**NOOB**
I am over riding the closing event for the main form, Windows Shutdown process halts until the application is manually closed. Then I have to initiate the shutdown sequence again.
Below I have the OnClosing event. I am looking to combine the two below so that they close out the application if Shutdown, Restart or Logoff are initiated.
protected override void OnClosing(CancelEventArgs e)
{
e.Cancel = true;
this.WindowState = FormWindowState.Minimized;
Hide();
}
protected override void WndProc(ref Message m)
{
base.WndProc (ref m);
if (m.Msg == 0x0011)
{
Application.Exit();
//this.Close();
}
}
If I have these 2 methods in place, the application WILL shutoff, BUT it will also halt the shutdown process, and once again I have to start the shutdown process all over again.
Thank you in advance for your help.
**DAN**
|
|
|
|
|
Calling Application.Exit sends the WM_QUIT message to the application, this the pump catches and the WM_CLOSE event is not (typically) called, so OnClosing is not executed. That much you've discovered. When handling the WM_QUERYENDSESSION notification message, though, you should set Message.Result = new IntPtr(1); in order to essentially return TRUE as the return value so that the shutdown process isn't canceled. By not setting this value, FALSE is essentially returned and the shutdown process is cancelled as you have noticed.
For more information, see the documentation for the WM_QUERYENDSESSION notification message at http://msdn.microsoft.com/library/en-us/sysinfo/base/wm_queryendsession.asp[^] and pay close attention the return value documentation and the remarks section. Hopefully this will help, but it won't combine those two handlers. Honestly though, it really doesn't matter - it solves the problem and that's what counts. Besides, the Closing event is triggered by the WM_CLOSE message which isn't sent to Windows unless the application pump handles an appropriate message and sends or posts the message itself (at least, from what I remember).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I seem to be encountering difficulty while trying to delete an item from a listbox. The user selects an item from the listbox, then clicks a delete button. The button code is as follows:
<br />
try<br />
{<br />
listBox1.Items.Remove(listBox1.SelectedItem);<br />
}<br />
catch(IndexOutOfRangeException ex)<br />
{<br />
MessageBox.Show("Could not delete the selected item", "Error", MessageBoxButtons.OK);<br />
}<br />
<br />
Now, if I select the first item in the list, and press delete, the exception IndexOutOfRange occurs, however the item is then successfully deleted. If I select any other item in the list and try to delete it, it works fine, no exception
Why does deleting the first item cause an exception
|
|
|
|
|
I test your code and there is no problem with that. It works properly for all items. Whats your error message?
Mazy
No sig. available now.
|
|
|
|
|
i just get an "IndexOutOfRangeException" occuring. Im using Borland C# if thats any help?
|
|
|
|
|
Gavin Coates wrote:
i just get an "IndexOutOfRangeException" occuring
Every exeptions have a Message property, which is string contained a error string.
Gavin Coates wrote:
Borland C#
Oh, I don't know about that. I haven't seen anybody use it here.
Mazy
No sig. available now.
|
|
|
|
|
error is:
"Index was outside the bounds of the array"
|
|
|
|
|
Try
private void btnDelTheListBoxItem_Click(object sender, System.EventArgs e)
{
if(TheListBox.SelectedItem != null)
{
for(int i = 0; i < TheListBox.Items.Count; i++)
{
if(TheListBox.SelectedItem.Equals(TheListBox.Items[i]))
{
TheListBox.Items.RemoveAt(i);
i = TheListBox.Items.Count;
}
}
}
}
This will work
|
|
|
|
|
ggthanks thomasa.
I tried the code above, but again i get exactly the same results! I can delete any item in the listbox no problems, but when i try to delete the first item, it deletes, but causes an IndexOutOfRangeException!!
I tried creating a whole new project with just a listbox, textbox add and delete button, and it worked perfectly, no errors at all. It just causes problems in my current project!!!
Please help!
|
|
|
|
|
Strange.
You should sett up some breakpoints and find out what index the first Item in your listbox has. It should have index 0.
It might be that you add the item to your listbox in a special way?
I use:
TheListBox.Items.Add("Some text");
|
|
|
|
|
What is the most efficient way to wait for a worker thread to complete. I'm making a file sending program and I want to only send one file at a time (i.e. wait for the previous send to finish), but I want the user thread to keep processing messages because I have status indicators and other options that need to be available while sending.
|
|
|
|
|
Sounds like what you want is one dedicated thread that sits idle in an infinite loop waiting for files to send. Each send request would be enqueued into a blocking queue. The dedicated thread wakes up when an item is available in the queue and processes it accordingly.
|
|
|
|
|
Thanks for the reply,
I was thinking too hard, I solved the problem with a single boolean value that I set when I begin and end a send thread, the user thread just check the value of the boolean...somtimes its too easy to see.
|
|
|
|
|
You should look at invoking delegates asynchronously as well: Including Asynchronous Calls[^]. Might help solve the problem another way, even though I see you have solved it using state (just make sure you synchronize access to that state using a Monitor - ala the lock keyword if you like - against a static object or something similar).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello!
I have a combobox with autocomplete.
This combobox is linked to a field of a database.
I want to do this and I don't know how:
When I choose an item of the combobox to display in a form automatically
the information of that field.
I've made the form and I linked the controls to database using Bindings.
I use OleDb.
Please help me!
Thank YOU!
|
|
|
|
|
Hi, I've just spent weeks making a huge 'wizard' type form for a client and then they phone me today and tell me they want it as a windows form because its costing them too much money entering the data on the internet
What I really want is a utility for converting web forms to windows forms but since I realise this may not exist can anyone offer me any tips on how to convert it.
What I really need is longhorn here now and XAML.
tia
|
|
|
|
|
|
Hi Colin,
Unfortunatley we got the money up front, which seemed like a good idea at the time because it was good money
I can convert most of the form fields to their windows equivalent with a find and replace and most of the form logic is well encapsulated. The only real problem is then I've got to position all the form fields, actucally that is a nightmare because theres over a 100 textboxes and groups of radio buttons etc etc.
Cheers.
|
|
|
|
|
If you get REALLY (and I mean REALLY) desperate, you could host your ASP.NET solution on each machine .
I'd look at it as a learning opportunity, and a chance to do a UI exactly how you want it .
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Actually thats a very good idea, I remember hearing something about 'Cassini' and hosting asp.net runtime in a windows form.
Im just worried thats theres some big gotcha that will bring the whole idea to a halt.
Has anybody had any success with that approach.
Kentamanos wrote:
I'd look at it as a learning opportunity
LOL, its true, you do learn more on 'nightmare' projects, whatever doesn't kill me makes me stronger and all that
Thanks.
|
|
|
|
|
I am getting a weird problem with the tabpage here is a step by step account of how to reproduce my problem
1) add a tabcontrol and then a tabpage to a form
2) add a custom contorl to the tabpage (a normal control eg label will work as well but i am using a custom control)
3) add functionality that allows you to drag the control/label (i just use the controls mousedown to start DoDragDrop, and then use the drag_enter/move events of the tabpage to make it drag)
4) now set a background image, some big image say 1mb and 1024x768 and drag the contorl/label, you should see that it is slow to paint the control when dragging
HOW CAN I MAKE THE PAINTING SMOOTH?
I have tried double buffer overriding onpaintbackground etc.. but that is not the solution as if i add my control to a panel and then set the panels backgroundimage to a large image the painting is smooth!!!! So the panel does something to make painting smooth that the tabpage does not. The solution i have come across is detailed below however it has a weird problem which i will list below. For now use the following steps to produce my problem
Start a new project
1) inherit from tabpage and produce a custom tabpage class with the code below
public class MyTab : TabPage
{
public Image imagex;
public MyTab()
{
}
protected override void OnPaint(PaintEventArgs e)
{
if(imagex!=null)
{
e.Graphics.DrawImageUnscaled(imagex, 0, 0, imagex.Width, imagex.Height);
}
base.OnPaint (e);
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
base.OnPaintBackground (pevent);
}
}
2) add tabcontrol to form and add the inherited tabpage to it
3) add user control to tabpage then add functionality to drag the control
4) make an Image object in the and set it to a large image in the form class name it LARGE_IMAGE
e.g. Image LARGE_IMAGE = Image.FromFile(@"C:\image.jpg");
5) add 4 buttons to the form which the following in their click events
Button 1
========
tabpage.imagex = LARGE_IMAGE;
Button 2
========
tabpage.imagex = null;
Button 3
========
tabpage.BackGroundImage = LARGE_IMAGE;
Button 4
========
tabpage.BackGroundImage = null;
6) OK now that everythings ready we can begin the test! If you press Button 1 you will see that when you drag the control the image appears underneath it however the painting isnt very smooth but is smoother than in the first example above where you set the backgroundimage. Now if you press Button 2 so the tabpage.imagex is set to null. painting should be smooth again as no background is set. (Forget about the backimage getting erased and painting when u move the control i understand why that is happening that is not the Problem).
Now press Button 3 to set the tabpage's backgroundimage and drag the control around it is slow to paint now press button 4 to set the backgroundimage to null. OK THIS IS THE WEIRD PART, Press Button 1 and tabpage.imagex should paint SMOOTH!!!!! IT is fine now.
I cant understand why this happens? It only paints smooth after setting and unsetting the tabpage's backgroundimage. I have tried doing the following
tabpage.BackGroundImage = LARGE_IMAGE;
tabpage.BackGroundImage = null;
tabpage.imagex = LARGE_IMAGE;
in the constructor of the inherited tabpage but that does not make it smooth, i have added the 3 lines of code to a seperate button again to no change. It seems i have to add the code to different buttons only then will it work!!! WIERD.
Please please can anyone shed any light on this situation? I want smooth painting on the tabpage with out pressing mulitples buttons LOL
|
|
|
|
|
Maybe if you active the DoubleBuffer (one buffer for display the actual paint, and one buffer for the next paint), you paint'll be more smooth. You can activate this Style with:
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
The Control Style UserPaint, and WmPaint are need them for DoubleBuffer.
----
hxxbin
|
|
|
|