|
Dear all,
I want to create a large .txt file but when i run my code i got a strange thing,
A messagebox say's: "No Symbols are loaded for any call stack frame. The source code cannot be displayed."
and a warning say's "The CLR has been unable to transition from COM context 0x1c2000 to COM context 0x1c2170 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."
My code is:
string prev="";<br />
<br />
string connectionString = "Provider=Microsoft.JET.OLEDB.4.0;data source=E:\\ICA_Newspapers.mdb";<br />
<br />
OleDbConnection conn = new OleDbConnection(connectionString);<br />
<br />
string sql = "SELECT * FROM All_Analyzed_Corpus";<br />
<br />
OleDbCommand cmd = new OleDbCommand(sql, conn);<br />
<br />
conn.Open();<br />
<br />
OleDbDataReader reader;<br />
reader = cmd.ExecuteReader();<br />
<br />
StreamWriter tw = new StreamWriter(Application.StartupPath + "\\TaggedCorpus.txt");<br />
<br />
StringBuilder text = new StringBuilder();<br />
<br />
<br />
while (reader.Read())<br />
{<br />
if (reader.GetValue(1).ToString() == "/D")<br />
{<br />
text.Append("</s>");<br />
<br />
tw.WriteLine(text);<br />
tw.Flush();<br />
text = text.Remove(0, text.Length);<br />
<br />
text.Append("<s> ");<br />
prev = "/D";<br />
}<br />
else if (reader.GetValue(1).ToString() == "/T" && prev != "/D")<br />
{<br />
text.Append("</s>");<br />
tw.WriteLine(text);<br />
tw.Flush();<br />
<br />
text = text.Remove(0, text.Length);<br />
<br />
text.Append("<s> ");<br />
prev = "/T";<br />
}<br />
else if (reader.GetValue(1).ToString() == "/P" && prev != "/T")<br />
{<br />
text.Append("</s>");<br />
tw.WriteLine(text);<br />
tw.Flush();<br />
<br />
text = text.Remove(0, text.Length);<br />
<br />
text.Append("<s> ");<br />
prev = "/P";<br />
}<br />
<br />
<br />
<br />
if(reader.GetValue(5).ToString().Contains("/"))<br />
{<br />
pr1 = reader.GetValue(5).ToString().Split(char.Parse("/"))[1];<br />
}<br />
else<br />
{<br />
pr1 = reader.GetValue(5).ToString();<br />
}<br />
<br />
if (reader.GetValue(6).ToString().Contains("/"))<br />
{<br />
pr2 = reader.GetValue(6).ToString().Split(char.Parse("/"))[1];<br />
}<br />
else<br />
{<br />
pr2 = reader.GetValue(6).ToString();<br />
}<br />
<br />
if (reader.GetValue(7).ToString().Contains("/"))<br />
{<br />
pr3 = reader.GetValue(7).ToString().Split(char.Parse("/"))[1];<br />
}<br />
else<br />
{<br />
pr3 = reader.GetValue(7).ToString();<br />
}<br />
if (reader.GetValue(8).ToString().Contains("/"))<br />
{<br />
stm = reader.GetValue(8).ToString().Split(char.Parse("/"))[1];<br />
}<br />
else<br />
{<br />
stm = reader.GetValue(8).ToString();<br />
}<br />
<br />
if (reader.GetValue(9).ToString().Contains("/"))<br />
{<br />
suf1 = reader.GetValue(9).ToString().Split(char.Parse("/"))[1];<br />
}<br />
else<br />
{<br />
suf1 = reader.GetValue(9).ToString();<br />
}<br />
<br />
if (reader.GetValue(10).ToString().Contains("/"))<br />
{<br />
suf2 = reader.GetValue(10).ToString().Split(char.Parse("/"))[1];<br />
}<br />
else<br />
{<br />
suf2 = reader.GetValue(10).ToString();<br />
}<br />
<br />
if (reader.GetValue(14).ToString().Contains("/"))<br />
{<br />
cas = reader.GetValue(14).ToString().Split(char.Parse("/"))[1];<br />
}<br />
else<br />
{<br />
cas = reader.GetValue(14).ToString();<br />
}<br />
<br />
<br />
text.Append(pr1 + "+" + pr2 + "+"<br />
+ pr3 + "+" + stm + "+" + suf1<br />
+ "+" + suf2 + "+" + cas + " ");<br />
<br />
<br />
text = text.Replace(" +", " #+");<br />
text = text.Replace("+++", "+#+#+");<br />
text = text.Replace("++", "+#+");<br />
text = text.Replace("+ ", "+# ");<br />
<br />
<br />
}<br />
<br />
tw.Close();<br />
<br />
reader.Close();<br />
conn.Close();<br />
<br />
Thanks in advance...
|
|
|
|
|
It seems that a COM object needs to respond within 60 seconds, but you create someting in this time.
Is this an operation you run in your main tread (or the thread which created a window)?
I would try to execute Application.DoEvents(); every loop iteration.
Greetings
Covean
|
|
|
|
|
When I did Application.DoEvents(); no message appears but the file size stopped at 7805 kb and the program stopped and thats cant be because the file must end with the last record in my database table.
|
|
|
|
|
Are there no exceptions?
I looked over your code and couldn't find any problem, so I tried if there is maybe a problem with the filesize (I haven't really awaited that there is an error and there is no error. I was able to create an 9GB large text file without problems).
Do you use any other COM-objects in your project?
At next I would try to do this database-"export" in an own thread.
Greetings
Covean
|
|
|
|
|
Hi, in my database I have a bunch of sums which for example can be broken down to (100*25)/3 or whatever the case may be.
How would I work out programatically the sum in the string in my C# app?
Thanks.
Strive to be humble enough to take advice, and confident enough to do something about it.
|
|
|
|
|
Good question. I had thought .NET provided something for doing that sort of thing, but can't find it.
There are a number of projects on the net which provide functionality for doing that sort of thing. Here's one:
http://www.bestcode.com/html/bcparser_net.html
Regards,
Rob Philpott.
|
|
|
|
|
|
|
Hi,
I want to convert my text file to pdf file ?
is it possible in C#?
Thanking You
Sunil G.
modified on Monday, January 11, 2010 5:00 AM
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:13am.
|
|
|
|
|
I think PDFSharp is third party component.
I dont want to use third party.
|
|
|
|
|
You don't have a choice. There is nothing in the .NET Framework that reads/writes .PDF files natively.
|
|
|
|
|
Id PDFsharp copyrighted or free source ?
Can i use PDFSharp in my C# application?
Can u give the component?
|
|
|
|
|
|
hi..
what is the maximum buffer size in c#.
while i use
byte [] byte = new byte [MAX];
how much will i set maximum value MAX variable.
have ant restriction to set maximum buffer size . can i use this long.MaxValue
Thanks.
|
|
|
|
|
The effective limit is how much RAM your users are going to have.
Int32.MaxValue is about 2GB, which is probably too much to assume is present on your users' machines
Int64.MaxValue is about 1019 which is a ridiculously large number.
Why do you need such a large buffer in the first place? You might want to re-think your algorithm.
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
i will consider ... thanks for your reply
|
|
|
|
|
Dear developers,
I am coding a very small project for my study. I want to refresh form1 after form2 is closed. For example, I open form1 and click one button to open form2 and in form2 I can insert data to the database (ex : tblItem). In addition, combobox in form1 retrieves data from the database (tblItem) too. So, after inserting data from form2 and when I close the form2, I want the comboxbox in form1 refresh to retrieve the last update of tblItem data.
Please advise, thanks.
Visoth
Chuon Visoth
Angkor Wat - Cambodia
asp.net - c sharp beginner
|
|
|
|
|
How are you showing form2?
If you use form2.ShowDialog() , it won't return until you close form2, so you can just add code after this line in form1.
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
Let's see my code.
form2 frmitem = new form2();
frmitem.ShowDialog();
Many thanks,
Chuon Visoth
Angkor Wat - Cambodia
asp.net - c sharp beginner
|
|
|
|
|
Hi,
I am new to C#. I want to know what is COM Interop in C#.
|
|
|
|
|
You should
a) search on the internet
b) read a book
to learn about Com Interop.
Here is something to start you up[^].
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|
|
how to check if an ini contains a specific section?
|
|
|
|
|
|
There is a good and free iniParser:http://ndevilla.free.fr/iniparser/
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 8:59am.
|
|
|
|