|
I always have trouble debugging methods (doing a watch, for example) over methods that pass some information to another thread and wait for the result, as the other thread is keept suspended while evaluating is done.
Is there any way to mark a thread to be "invisible/unstopable" by the debugger?
|
|
|
|
|
AFAICT, there's no way to do this. Once the app breaks in the debugger, all threads stop along with it.
|
|
|
|
|
I made a big mistake. The code bellow tells everything:
private void SearchFolders(FileSystemInfo[] fsInfos)
{
foreach (FileSystemInfo fsi in fsInfos)
if (fsi is FileInfo)
try
{
ReplaceInFile((FileInfo)fsi, "textToSearch", String.Empty);
}
catch {}
else if (fsi is DirectoryInfo)
SearchFolders(((DirectoryInfo)fsi).GetFileSystemInfos());
}
private void ReplaceInFile(FileInfo fi, string searchText, string replaceText)
{
StreamReader reader = new StreamReader(fi.FullName);
string content = reader.ReadToEnd();
reader.Close();
content = Regex.Replace(content, searchText, replaceText);
StreamWriter writer = new StreamWriter(fi.FullName);
writer.Write(content);
writer.Close();
}
So i have a recursive function SearchFolders witch searches an expression in all files from a folder. The problem: well i forgot to put the condition that the search should be done only on text file. So the function just executed on every kind of file (jpeg, gif, pdf, doc, etc.). The result: the files are unreadable. Tryng to reverse the proces with someting like this had no result
private void Reverse()
{
FileInfo fi = new FileInfo(@"D:\test\test.jpg");
FileStream fs = fi.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None);
StreamReader sr = new StreamReader(fs);
string content = sr.ReadToEnd();
System.Text.UTF8Encoding utf8 = new UTF8Encoding();
byte[] bytes = utf8.GetBytes(content);
FileStream fstarget = File.Create(@"D:\test\reverse.jpg");
fstarget.Write(bytes, 0, bytes.Count);
fstarget.Close();
}
I think the files are lost but i just want to hear and another opinion.
|
|
|
|
|
cristi82gt wrote: ReplaceInFile((FileInfo)fsi, "textToSearch", String.Empty);
No, it's not reversible. What you did was replace every occurance of a certain text with nothing. Now you have no idea where to put the text back into the files. If you replaced it with a known string, that would be different, but since you used String.Empty, you've lost any hope of knowing where to put back the bytes you took out.
The bottom line is those files are hosed up beyond repair.
|
|
|
|
|
Thanks for the answer Dave. Well i don't want to bring the text files to the way they were before, only the other types of files (jpeg, pdf).
Let's neglect for a little the function ReplaceInFile , because the expression to replace was pretty long (around 60-70 characters) and i don't think that in an image read as text would find it(very improbably)
The problem is that i read an binary file(for example an image-JPEG) with a StreamReader (UTF8 encoding) as a string, than i wrote that text with a StreamWriter overwriting the original file. (the function i wrote was clearly meant for text file but i forgot to limit it only to those type of files)
The problem is that the image file is now unreadable because it has been written as a text file with UTF8 encoding. I know that in case of Base64Encoding reading a binary file as text wouldn't be a problem, because the text can be reverted back to bytes so that would again compose a valid image(jpeg) for example
In the case i did i don't think this is possible. Any ideas?
|
|
|
|
|
I'll ignore that you shouldn't have written a file that you didn't change...
Since the conversion from binary to UTF-8 is "lossy", there is no way to go backwards.
|
|
|
|
|
OK thanks again Dave. That's all i wanted to hear.
|
|
|
|
|
To which is passed like destination a project, and generates Web Service and publishes to in Internet Information Server.
in Visual Studio 2008. to Framework 3.0 or 3.5 in c#
Existe alguna función en el Framework de .net, que pasándole el destino de un proyecto creado en Visual Studio, me genere del proyecto un Web Service y me lo publique en Internet Information Server.
Gracias
|
|
|
|
|
Please don't cross post. You have asked the same question in ASP.NET Forum.
|
|
|
|
|
Hi all,
I have created a windows application,in that 1 MDI parent and 2 child forms are there....i have opend 2 child forms,now if i add anything in the first window textbox that should get updates in the second window's dropdown,bcz the value which i entered in the first window is get stored in the database,and the second window dropdown is populating form that table...
This is not happening...how to do?...
(2 windows are of child of the same parent window..)
Thanks in advance...
|
|
|
|
|
The simplest way is to create a method in form2 that refreshes the dropdown and call this method from form1 when text is entered in the text box. But and ideal solution would involve using delegates to achieve loose coupling.
Hope this helps,
Shameel
|
|
|
|
|
Ok, I first want to say that I am VERY new to visual studio 2008. So, this may be an easy question to answer for many of you. I have created 10 forms and what I noticed is that 7 of the forms have the same controls. The other 3 forms have have the controls as well but 3 addition controls have been added to the form. My question is 2 fold. One, how do I copy or clone one of these forms including the code to another new form. I have tried a few things in the past but the controls do not stay in the same location so I am sure I have yet to find the right way to do it. The second question would be what way would you handle this situation. Let's say you have your form and that form has 4 controls. You need another form that has all the same controls and properties as the previous form but with an additional 2 controls. Is the parent/child method the only way to do this and if so what limitations with classes and objects. Considering, I am a begginer any help would be appreciated.
Thanks
|
|
|
|
|
What you are talking about is called 'Visual Inheritance' in .Net/VS.
You didn't say which language but here is a link[^] for VB.Net, it uses a previous version but is still relevant, and another[^] for C#.
If you google for vb.net visual inheritance or c# visual inheritance you will find lots of help.
And here[^] is a sort of tutorial with code download for both languages.
Hope this helps!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Very confused here!
I can't work out how the runtime changes the border of my button to orange from blue when the mouse pointer hovers over it!
Because no mouse event handlers are defined in the application, so where is this behaviour coming from??
Clearly if this was a web app, I could easily guess that some client script was doing this, but it is simply an ordinary .NET 3.5 windows app!
|
|
|
|
|
mnemonic69 wrote: Because no mouse event handlers are defined in the application, so where is this behaviour coming from??
This is the default behaviour of the control. Take a look at this information on MSDN[^] for further details.
|
|
|
|
|
Hi,
I did take a look at MSDN and it doesn't explain what that 'standard behaviour' is or how that 'standard behaviour works'
Thats why I thought, someone on here might know the answer!!
|
|
|
|
|
mnemonic69 wrote: I did take a look at MSDN and it doesn't explain what that 'standard behaviour' is
Yes, sorry, but as usual Microsoft tend to hide this sort of detail deep in the reference guides. I had assumed that a link to the Button control would give you what information you sought. Suffice to say that you can overrirde almost everything in your application just by changing properties and/or implementing event handlers.
BTW, does the lack of this information prevent you from completing some part of your work?
|
|
|
|
|
I think you are talking about the Luna theme in Windows XP. It is taken care by Windows XP and you don't have to worry about it. Change your Windows theme to Classic and you will see what is happening.
Regards,
Shameel
|
|
|
|
|
;?xml version="1.0" encoding="utf-8"?>
<dataConfiguration>
<xmlSerializerSection type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<enterpriseLibrary.databaseSettings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" defaultInstance="Database Instance" xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/data">
<databaseTypes>
<databaseType name="Sql Server" type="Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase, Microsoft.Practices.EnterpriseLibrary.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</databaseTypes>
<instances>
<instance name="Database Instance" type="Sql Server" connectionString="Server=awsqlt25vs01;Database=SW2_phone_interview;Integrated Security=true;" />
</instances>
<connectionStrings>
<connectionString name="Server=awsqlt25vs01;Database=SW2_phone_interview;Integrated Security=true;">
<parameters>
<parameter name="database" value="SW2_phone_interview" isSensitive="false" />
<parameter name="Integrated Security" value="true" isSensitive="false" />
<parameter name="server" value="awsqlt25vs01" isSensitive="false" />
</parameters>
</connectionString>
</connectionStrings>
</enterpriseLibrary.databaseSettings>
</xmlSerializerSection>
</dataConfiguration>
I have the above code snippet in my windows application. Now in some methods I am getting tome out exception. So I need to add one more instance for Microsoft.Practices.EnterpriseLibrary.Data.SQL.SQLCommandWrapper to set the connection time out property for a constant value in config file
Please advise
Thanks in advance.
-
|
|
|
|
|
Hi,
I have written a stored procedure in which some insert and update statements are there. This SP i'm running in my local PC and inserting & updating some tables from remote sql server to my local sqlserver.
Now the problem is that this SP is taking too much time to execute, app. 5-7 min.
Now plz advice me some optmize solution for this.
Thanx...
krishna veer singh
|
|
|
|
|
There's far too little information here for anybody to offer you reasonable help. If I were you, I'd look to run a SQL profiler on the stored procedure and analyze the results from this. This will tell you where your holdups are.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Colleagues,
I would like to populate WPF DataGrid with data that my program generates on the fly and without a database or a file. Could you suggest me how to do it?
Tips, hints, references, insight are all appreciated!
Cheers,
- Nick
|
|
|
|
|
Create a business model and populate it into an ObservableCollection. That's the most basic thing I can think of for you. There are plenty of tutorials around that demonstrate how to do this.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I am in the middle of creating a program for people that play pen-and-paper RPGs to roll dice on their computer (like this program), but utilizes a server/client based-IM portion to send the die roll results to all the clients and I am going to modify the following code as given here: http://www.devx.com/dotnet/Article/28253/0/page/2 to do that.
As this is my first time creating a program that utilizes anything having to do with sockets, I have a couple of questions that I have yet to find an answer about on Google, various programming sites, or other forums. Here are my questions:
- The server will not be static, as in not always on the same LAN and with the same IP address. I intend for the person acting as the server to be able to start the server and act as the server on any LAN they happen to be attached to. How do I get the server to broadcast its IP/HOSTNAME so that clients can attach to it without the person who is acting as the server having to give the others the information to log in. For example, the person starting the server may be on a LAN with a network address of 192.168.xxx.xxx and another time on one that has an address of 10.1.xxx.xxx.
- That leads to the next question. How do I get the clients to detect the server? If there happens to be more than one "server" on the network (i.e., large gaming conventions and the like), I would like for the person trying to connect to be able to detect all of them and choose the correct one. Sort of like the person starting the server to give it a name like "[b][i]Big Al's Gaming Group[/i][/b]", not just using the Host Name of the computer.
- Just for the sake of my curiosity and knowledge, and I probably know the answer to this and have a way to send the rolls to the clients already, but can you send different datatypes other than strings over the connection and have them arrive as the same datatype? I currently have the rolls going into an arraylist to be displayed in a listview control, and would love the arraylist to be sent over the connection.
I have all but this portion of the program coded and operational.
Mike Rainey
--------------------------------
|
|
|
|
|
- IMO, server need not broadcast it's details. Just start the server and listen on a specific port. Also server should prompt to enter a name for it. This name will be send to clients for displaying. Make sure all your clients know the port which server is using.
- When each client is starting, it should send a message asking for the server to provide details. UDP is the appropriate protocol for broadcasting such kind of messages. .NET framework has a UdpClient[^] class which can be useful. Your client will broadcast a message something like SERVER_DETAILS. The server program should be able to grab this message and send the servers IP, name and other required details. Receive this details on the client and show the details.
- Data will be send as bytes always. You need a wrapper to convert the bytes to appropriate data type. There are open-source initiatives like protocol buffers[^] which will allow to send messages by providing type safety. But in reality, for a highly scalable application, designing your own message protocol works well.
Array list can be send after serializing it to bytes. Read about BinaryFormater class.
raineym wrote: I am going to modify the following code as given here: http://www.devx.com/dotnet/Article/28253/0/page/2 to do that.
That is too naive way of doing a scalable networking application. You should work with Sockets directly rather than with wrapper classes like TcpListener or TcpClient . I suggest this[^] MSDN article.
|
|
|
|