|
Hi,
That sounds like the problem to me. What's probably happening is the domain is getting unloaded while its event handler is still running, and that's confusing the CLR at a level below your exception handling.
Yes, that crossed my mind the minute the bug appeared, but the event handler adds the method to a method execution queue I designed and that queue is run in a separate thread, so the event handler 100% exits.
By crash I mean when i'm in debugging mode after i press step over over the AppDomain.Unload the debugging session ends and the application literally crashes...
The plugins do not unload themselves, a dedicated method execution queue runned by a thread that is created in the main AppDomain terminates them by processing the method I posted in the original post.
Thank you for your quick reply.
|
|
|
|
|
I'm not sure if you can unload a plugin from a different thread to the one that spawned it, come to think of it.
Running a queue in a separate thread is actually a really good way of having the unload happen before it should, unless you're applying a delay or doing some cross-domain interlocking.
I also agree with the other poster who said that you could try not unhooking the UnhandledException event handler. It should go out of scope and disappear anyway when the plugin reference is lost.
|
|
|
|
|
Hi,
After a session of debugging using all advices I collected, here are my findings (So everybody can learn from my mistakes... )
-A plugin can be unloaded from a different thread (other thread then the one that spawned it
-The problem was that I also handled UnhandledException event of the AppDomain, and a series of unfortunate events happened:
*I have 2 mechanisms for protecting my core system from plugins:
1. A watchdog timer mechanism that terminates a plugin if the plugin hasn't responded (raised an watch dog timer event) for a certain period of time
2.A UnhandledException event handler for when an unhandled error occurs in the plugin, and in that event i call UnloadPlugin function and remove the plugin from the core system
So a plugin spawned an unhandled exception the same time the watchdog timer called UnloadPlugin function... And in the UnhandledException handler it tried to use data and unload an already unloaded AppDomain
So the solution is to develop some kind of synchronization mechanism so if one request for termination comes that no other request are processed.
So the bottom line is "Threads are evil"
Thanks for your help.
|
|
|
|
|
unix_master01 wrote: // DOES NOT COME TO THIS PART
AppDomains, all of them even the main one, have an UnhandledException.
You should always set that because unhandled exceptions terminate the domain or even the application. And that is your last chance to at least try to report what the exception was.
|
|
|
|
|
Hi, when I select region combo, I can populate country combo but when I re-select region combo again, country combo append the listitem on top of the previous value. not sure why its happening. below is my code
protected void Page_Load(object sender, EventArgs e)
{
if (!(IsPostBack))
fillcombos();
ddRegion.SelectedIndexChanged +=new EventHandler(ddRegion_SelectedIndexChanged);
}
protected void ddRegion_SelectedIndexChanged(object sender, EventArgs e)
{
DataSet ds = new DataSet();
if (ddRegion.SelectedIndex >-1)
{
ds = myBLL.GetRegionOverviewAndCountryByRegionId(Convert.ToInt32(ddRegion.SelectedValue));
DataRow dr = ds.Tables[0].Rows[0]; // get the first row returned
if (dr.ItemArray.Count() > 0)
{
txtRegionOverview.Text = dr["RegionOverview"].ToString();
ddRegion.SelectedValue = dr["RegionId"].ToString();
}
if (ds.Tables[1].Rows.Count > 0)
{
ddCountry.DataSource = ds.Tables[1].DefaultView;
ddCountry.DataTextField = "CountryName";
ddCountry.DataValueField = "CountryCode";
}
else
{
ddCountry.DataSource = null;
}
ddCountry.DataBind();
}
}
public void fillcombos()
{
List<Region> regionList = new List<Region>();
regionList = myBLL.GetRegionList();
ddRegion.DataSource = regionList;
ddRegion.DataTextField = "RegionName";
ddRegion.DataValueField = "RegionId";
ddRegion.DataBind();
}
---
<asp:DropDownList ID="ddRegion" runat="server" AutoPostBack="true"></asp:DropDownList>
asp:DropDownList ID="ddCountry" AutoPostBack="true" runat="server" ></asp:DropDownList>
in addition, I wanna it to work when i add "select a region", "select a country" at the top with
ddregion.items.insert(0,"select.."
please help
|
|
|
|
|
A couple of things:
0) Change your Page_Load method to do this:
if (!IsPostBack)
{
fillcombos();
ddRegion.SelectedIndexChanged +=new EventHandler(ddRegion_SelectedIndexChanged);
}
1) Either clear the country combo box or check IsPostBack again before adding stuff to it.
2) Your question should have been put into the ASP.Net forum.
3) Learn how to use the <PRE> tag here for code snippets.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Ok I had to clear the combo in pageload but how do I add "Please select" in this situation?
-- Modified Wednesday, April 13, 2011 9:02 AM
|
|
|
|
|
if this is in fact an asp.net application that you are just using c# for the code behind..
in the properties window look for these things
Items (collection) set the first item in that collection to "Please Select" or whatever you wish
AppendDataBoundItems set to true
ViewStateMode = false
Go to the first box and set to AutoPostBack = true.
Programming is a race between programmers trying to build bigger and better idiot proof programs, and the universe trying to build bigger and better idiots, so far... the universe is winning.
|
|
|
|
|
Pls i want to create a shield to cover my screen so that
user will have to login to use the system,
i do not want to use the windows login.
thank you.
|
|
|
|
|
Enobong Adahada wrote: i do not want to use the windows login.
Why not? it does exactly what you want. If you are determined to develop your own alternative then these links[^] may help you.
|
|
|
|
|
On top of what the other poster said, that only works for Windows XP. There is no GINA in Windows Vista and above, so you'll have to create your own Credential Provider[^].
So, If you wanted to support both Windows XP and Vista and above, you'll have to write to entirely seperate projects. And you're not going to accomplish any of this in C#, at least, not as easily as you could in C++. All of the API's and SDK's, samples, and support are geared for C++.
Good Luck!
|
|
|
|
|
You can download a demo from what you want directly from Microsoft, here[^].
I are Troll
|
|
|
|
|
Place it in a safe that has a 4 digit PIN pad on the front.
"Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!"
— Hunter S. Thompson
|
|
|
|
|
hi
i face following problem in publishing the website.
Error 97 The type 'IqSiteWeb.CustomControls.DonationAgencyList' exists in both 'c:\Users\dell\AppData\Local\Temp\Temporary ASP.NET Files\iqsiteweb\5dc5d18b\b10a84ef\App_Web_jhddkwxc.dll' and 'c:\Users\dell\AppData\Local\Temp\Temporary ASP.NET Files\iqsiteweb\5dc5d18b\b10a84ef\App_Web_utdgqfe5.dll' C:\ProjectList\Kei Versions\KEI-WebSite\IqSiteWeb\Donation\DonationView.aspx 33
i tried a lot to surf the net and get the solution but i dint get any solid solution......
|
|
|
|
|
You have:
- Two dlls with the same class definition in somehow. Almost certainly the same dll twice. You'll probably will have to work out how this happened yourself.
Posted to the wrong forum: This should have been in the ASP.Net forum.- Reposted: See Mark's answer in the ASP.NET forum, his answer is the most common reason for this fault.
|
|
|
|
|
I have written a few classes to handle geometry primitives, like Length, Angle, etc, to make sure there are no unit mismatches as could happen if the values are stored in plain double types.
Coming from C++, I overloaded operator== et al, to compare the actual values, which to me would be intuitive. However, co-workers coming from Java claimed operator== should be reserved for comparing references, and that I should use Equal() and the like for comparison. The C#-ers here seems to be divided.
Is there a design guide for operator overloading in C#? How would you prefer the implementation? Operator overloading or plain old function calls?
|
|
|
|
|
I think there is not a clear rule for this. If you overload the other relational operators (<, > <=, >=) then I think that overloading == for bit equality makes sense. Rememeber you can always use the static method Object.ReferenceEquals to compare references.
|
|
|
|
|
You could always use Object.ReferenceEquals..
But, in my opinion, types like Length and Angle etc should be value types (and therefore structs, unlike in C++, in C# classes can never be value types) - they represent a value instead of a thing and in almost every situation will it be more intuitive if they also behave like values.
To counter his argument:
1) C# is not Java
2) operator== on strings compares for value-equality (even when you make sure that string-interning is avoided)
|
|
|
|
|
As long as it is clear in the documentation for your class that == does value equality checking, and that makes sense for how the class would normally be used, it is fine to do that in .Net. As mentioned below, string.== does that.
However, I also agree with the comment below that simple wrappers like that should be value types (structs).
Edit: Below=above. I forgot which way CP forums stack posts.
|
|
|
|
|
Niklas Lindquist wrote: co-workers coming from Java claimed operator== should be reserved for comparing
references
That's because Java got it wrong and they want to share the misery.
Use == for value equality in .net; it's right way, the intuitive way.
|
|
|
|
|
PIEBALDconsult wrote: That's because Java got it wrong and they want to share the misery.
Having seen some truly hideous usages of operator overloading including at least one that I wrote myself and having never seen any truly inspired usage of the same I would say that Java got it right.
So in terms of misery the win goes to C++.
|
|
|
|
|
jschell wrote: truly hideous usages of operator overloading
I would say that that describes Java.
C and C# are the only languages I consider.
|
|
|
|
|
PIEBALDconsult wrote: C and C# are the only languages I consider.
Myself I use languages that are appropriate for the job.
Those include C++, C#, Java, SQL (vendor specific implementations), Perl and various OS scripting languages.
Myself I wouldn't use C versus C++ unless forced.
Small differences in one language do not matter in terms of choice over another.
|
|
|
|
|
You can abuse almost any language feature..
The "no operator overloading" along with the "no structs" (though that one is not as bad) restrictions make it impossible to create proper new numeric types in Java, and that just sucks. It makes the predefined types more magic, and it makes working with any non-predefined numeric type a pain.
As for the abuse, sure, you can do that. You can also have overloads Foo(int) and Foo(long) and have them do something completely different - that's on the same level as operator overloading abuse, but Java still allows that. You can also override some method (accidentally even, in Java) and have it completely break the Liskov substitution principle.
|
|
|
|
|
David1987 wrote: The "no operator overloading" along with the "no structs" (though that one is
not as bad) restrictions make it impossible to create proper new numeric types
in Java, and that just sucks. It makes the predefined types more magic, and it
makes working with any non-predefined numeric type a pain.
Since the vast majority of programming in the world does not involve that it isn't a significant problem.
And since most programs that do deal with specialized numerics often have other requirements, such as performance and or significant other functionality (non-numeric) then one should either choose an appropriate language or live with the small amount of code that java entails.
The obvious analogy to that is that SQL is very poor candiate for string manipulation and regexes and thus applications used widely, such as editors, should not be written in SQL. That however doesn't mean that SQL suffers because of it.
David1987 wrote: As for the abuse, sure, you can do that. You can also have overloads Foo(int)
and Foo(long) and have them do something completely different - that's on the
same level as operator overloading abuse, but Java still allows that. You can
also override some method (accidentally even, in Java) and have it completely
break the Liskov substitution principle.
No.
It is not a question of whether abuse can happen.
The point is that it does happen.
Enough so that me and others have seen it.
And it is not accidental.
|
|
|
|