|
Hi,
I am facing some problem with the threads in my application. I changed the threading attribute from MTAThread to STAThread due to some reason and because of that I am facing an contextswitch deadlock exception after approx every 4 mins.
The Exception:
ContextSwitchDeadlock was detected
Message: The CLR has been unable to transition from COM context 0x159bc0 to COM context 0x1598e0 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
In few of the forums, people have said that there is no harm in disabling this exception in the following way -- "Simply uncheck the ContextSwitchDeadlock exception under Debug.Exceptions.Managed Debugging Assistants if you just want to ignore the exception in the debugger".
I want to know if there will be any performance issues or memory leakage of any sort. Will this affect my over all application in any way.
Please help me on this.
Thanks
KR
|
|
|
|
|
What i would do is compile the code as "Release" and run this from outside the Visual Studio Dev environment. If the problem is not present then you may simply ignore the exception.
|
|
|
|
|
My code is,
AxMSChart20Lib.AxMSChart chart = new AxMSChart20Lib.AxMSChart();
chart.Title.Text = "My first chart";
this.Controls.Add(chart);
When i use this code, i get this exception,
"InvalidActiveXSateException was unhandled"
Exception of type:
'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown.
Can u tell, how can this be corrected?
Thanks-Guna
|
|
|
|
|
To get rid off that exception, Just add the control first with your container before using any of it's properties or methods.
AxMSChart20Lib.AxMSChart m_objChart = new AxMSChart20Lib.AxMSChart();
this.Controls.Add(m_objChart);
m_objChart.Title.Text = "My first chart";
|
|
|
|
|
iam workin in c#2005(desktop applications) i used datagird and i want to merge some columns together to appear as parent header to theses columns like the property (merge)we use it in excel to merge cells from columns to appear as one cell
ma_refay
-- modified at 3:24 Thursday 1st February, 2007
|
|
|
|
|
You'd have to define a template for your grid so these 'columns' are one column to begin with.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi everyone!
How to get Office 2003 color?
Office 2003 Color not like Xp Color.
I just get color.
Thank You.
Sorry for bad English
|
|
|
|
|
You'd need to download a UI library to make your app look like Office 2003.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi,
I am writing a project here in Australia that hopefully will be used in many other cultures.
I am having troubles coming to grips with how to handle different cultures particularly as it relates to database date/time formats and the various controls that rely on culture information.
Specifically, the database that the project revolves around is MS Access. Concentrating on just one field I have created - the DOB and is obviously a date/time field. The dates in the db are in English - Australian format ie dd/mm/yyyy.
I want to be able to enter the DOB into this field and would like to use a maskedtextbox to do this. Unfortunately, the provided mask (.Net v2) for date doesn't work whether I specify that controls English - US OR the English - Australia cultures. Essentially, if the first field (either whether it's month or day depending on the culture selected in the Control setting) has a 0 as it's first number, the date is not displayed correctly nor is it recorded in the DB correctly.
I have managed to avoid this issue up till now by formatting the user input into mm/dd/yyyy format for input into the database however this is not an apparent option with the maskedtextbox.
Can someone point me to a good tutorial on culture in the .Net framework and especially to VS2005 or perhaps at least guide me in the right direction? I would rather a hands-on tutorial rather than the heaps of theory and high level discussion type web sites. I need practical help
Is it preferable to ignore the local culture and force programatically all data (including the MS Access database) to be in a specific culture. If so - how?
Thanks in advance.
Glen Harvy
|
|
|
|
|
If you're using a datetime format in the database, and the DateTime object in your code, then the only issue is how you render the details in your UI layer. You can check in your UI layer for the correct way to render the display/input controls. Or, just use a calendar control, that's always the same, and show dates as 12 Jun 2006, for example.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Thanks for your prompt response.
What you said is what I thought and that was what I have been doing for some months now. I have cheated a bit by using the calendar control for any date input needs - avoiding the issue!
The problem is that the calendar control is not suitable for the task (try scrolling back 30 years for example) so I'm trying to use the maskedtextbox control to enter a DOB. This control is bound to the DOB field in the appropriate table.
I made the maskedtextbox culture neutral, eng-aus and eng-us and none of those cultures render the DOB in the correct format.
It seems that if the month or the day is a number less than 10, the leading 0 is dropped of when reading the value from the datatable and rendering it in the masked textbox.
This is the first time I have used a maskedtextbox so perhaps I am missing the obvious
Any suggestions.
Glen Harvy
|
|
|
|
|
The masked text box sucks, I always roll my own.
If you're using a text box, then you will need to detect the settings, and change the behaviour accordingly.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Christian Graus wrote: The masked text box sucks, I always roll my own.
I played around with them some months ago and gave up. I gave up again about 2 hours ago.
I've now got comboboxes and it works like a charm - well until I find the next problem
Thanks for your help - much appreciated.
Glen Harvy
|
|
|
|
|
You just need to handle the keypressed event, and set e.HAndled to true, to reject a keypress.
Actually, I have a winforms app, and I am finding the same problem, when I accept dates as text, or store them as text in XML, if the locale changes, it just blows up.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi there,
Is it possible to determine the request and response packet size of a Web Service?
Say... I would like to create a progress bar on my application to determine how many percentage the web service has performed.
My idea is first to determine the packet size of the xml document sent/received by the web service.
Then update the progress bar every, say... 10 kb, as the web service performs.
So anyone please tell me how to determine the packet size using C#.
If there is a better approach, please do not hesitate to suggest me.
Thank you very much.
KiT
|
|
|
|
|
I have a simple form containing only a DataGridView control. I would like the form to grow or shrink to fit the contents of the DataGridView. Of course the DataGridView would also need to grow and shrink to fit it's contents. Any suggestions?
|
|
|
|
|
If you set the anchor property of the grid, then you can just set your form's size, and the grid will follow. Measuring how big it should be is a little more complex, but you can ask the data source for a row count, as a starting point.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I set-up a project that does an ocr using the MODI dictionary. I'd like to do the same for barcode recognition of scanned documents. Does anyone know where I should start on this. Thanks.
|
|
|
|
|
CAn someone please help to decipher why I am getting the follwoing message: "C:\Class Test\Class Test 2\OrigClass.cs(26): A namespace does not directly contain members such as fields or methods"
Please see the code below. It looks fine to me.
using System;
namespace ClassTest2
{
///
/// Summary description for Class1.
///
class Point
{
public Point()
{
Console.WriteLine("This is the default constructor");
}
public Point(int x, int y )
{
Console.WriteLine("x:{0}, y:{1}", x, y);
}
}
static void Entrance()
{
Point Origin = new Point();
Point bottomRight = new Point (600, 800);
}
}
Skan
If you knew it would not compile why didn't you tell me?!?!?!
|
|
|
|
|
On an indented view, it would be more obvious, but it seems your Entrance method is not
inside any class, and that's what gets rejected.
In C# all code and data must reside inside a class, a namespace can only contain types
(such as class, struct, enum).
If your coming from C or C++ this may be a surprise.
Now when you create a project in Visual Studio, you will get a class for free
(named Form1 or something, depends on the kind of project).
Also I expect the compiler to tell you exactly which line it did not like.
If all of this is mysterious, I suggest you start reading a book on C# and have
a look into one of the beginners articles on CodeProject...
Luc Pattyn
|
|
|
|
|
Thanks for your prompt response. I do have a C++ background thus thinking by using Void it should be covered but evidently not so. I tried using additional brackets but to no avail. I receive the following error:
Program 'C:\Class Test\Class Test 2\obj\Debug\ClassTest2.exe' does not have an entry point defined
As to your suggestion about using a C# book I have started doing that and ironically this code was one copied directly out of the book.
Thanks
-- modified at 19:20 Tuesday 30th January, 2007
Skan
If you knew it would not compile why didn't you tell me?!?!?!
|
|
|
|
|
Skanless wrote: ironically this code was one copied directly out of the book.
If this was a Microsoft Press book then I'm not surprised. Many code examples in MS Press books have had syntax errors in them. There is obviously not enough QA done at the proof reading stage.
|
|
|
|
|
Your guess was right...................it is a microsoft press book and I have to admit that I had found several error in there ASP.net book too but I di not know C# enough to identify the errors. Wow...............I guess there are a lot of people who use these book just to find out how erroneous they are.
Skan
If you knew it would not compile why didn't you tell me?!?!?!
|
|
|
|
|
I have a DataGrid and also this code:
Can tell me anyone syntax for my code?
code: DataBinder.Eval(Container, "DataItem.id&ort", "detalii.aspx?id={0}&ort={0}")
Thanks
|
|
|
|
|
This code goes in your template for columns in your grid. It should get the item specified by the second parameter, and presumably stuff it into the {0} parts of the format string, which it then returns.
Do you want to get two values out ? You'd have to do that seperately, I generally write a code behind method that I pass the data item to, and evaluate it in code.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|