|
the exception is not really on that line. its somewhere inside the Form1 class. can you post the complete exception stack ? try to debug your application step by step you can able to track down this error.
|
|
|
|
|
Yes you are right. This is what i found in intellitrace:
Exception:Thrown: "The process cannot access the file 'd:\deneme\OCTOPUSxml-66907571 - Copy.xml' because it is being used by another process." (System.IO.IOException)
A System.IO.IOException was thrown: "The process cannot access the file 'd:\deneme\OCTOPUSxml-66907571 - Copy.xml' because it is being used by another process."
Exception:Thrown: "Exception has been thrown by the target of an invocation." (System.Reflection.TargetInvocationException)
A System.Reflection.TargetInvocationException was thrown: "Exception has been thrown by the target of an invocation."
In created method of filewatcher, i have these codes:
XmlDocument xdc = new XmlDocument();
xdc.Load(e.FullPath);
Somehow, grasping the file by filewatcher and loading by xmldocument occur almost at the same time. To be sure i changed the code as :
XmlDocument xdc = new XmlDocument();
System.Threading.Thread.Sleep(1000);
xdc.Load(e.FullPath);
System.Threading.Thread.Sleep(1000);
I know this is not professional but now it is working
|
|
|
|
|
Sleep is not the right choice. can you paste the code on how you initialize the file watcher instance. I guess its FileCreated event you are watching,while other application create and manage the file you are trying to load this in your form.
|
|
|
|
|
FileSystemWatcher doesn't "grab" files. It doesn't touch them at all.
The file is either being held open by your process using some other method, or some other process has the file open and locked, like something that outputs the file?? Or some editor??
|
|
|
|
|
leone wrote: Do you know why?
..because of an unhandled error in a constructor, probably the one from Form1 . Paste your code and we'll have a look.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
In a C# 2008 desktop application, the application is having a problem
determining if a folder exists on a network drive.
I am using code that looks like the following:
using System.IO
if (!File.Exists(myfile))
Console.WriteLine("The file does not exists.");
The value for the directory comes from a column in the database that
looks like the following:
//servername/mdain/myfile.xls".
Thus can you tell me what I can do so this application is aware that the file does exist on the network drive?
|
|
|
|
|
The first thing I see is that your sample path you provided is wrong. You are using the wrong slash in the path, it should be "\\servername\mdain\myfile.xls". The second thing I would check is if the computer you are running the application on has permissions to access the network drive, since that would return false regardless of the file existing.
|
|
|
|
|
Forward slashes are fine in path names; Windows correctly interprets them.
Use the best guess
|
|
|
|
|
Richard MacCutchan wrote: Forward slashes are fine in path names; Windows correctly interprets them.
Windows, yes. Most apps do not.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: Most apps do not. Well, you would not expect Microsoft's apps to do things properly, would you?
Use the best guess
|
|
|
|
|
Richard MacCutchan wrote: Well, you would not expect Microsoft's apps to do things properly, would you?
If I wouldn't, I'd be recommending to use GNU/C, OpenOffice, MySql and black magic.
Still I recommend to pay up for Microsofts' apps
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I'm not sure how easy that would be but perhaps the DirectoryInfo [^] or FileInfo [^] classes would help.
Use the best guess
|
|
|
|
|
|
I'm developing WCF silverlight application in C#.net 2010.
My question is simple, i'm getting WPF child window form name from database.
now i want to open that Child Window form using name/string coming from database. How to convert that string value into Child Window or do you have any other best solution solve for this. please help me thanks for you all
|
|
|
|
|
I think you would need to use Reflection[^].
Use the best guess
|
|
|
|
|
You're trying to open a WPF window in a Silverlight application using WCF to retrieve the WPF window? Good luck.
|
|
|
|
|
How funny, I was thinking exactly the same thing in more or less the same way even.
|
|
|
|
|
Now you're being obtuse, you know he is trying to get the name of the window from the database, opening a WPF window in silverlight is going to be a challenge I'll admit!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
msbuild and Visual studio seem to resolve project dependencies differently: a solution file contains the project for the main executable, and some projects for dlls the executable depends on. One of these dll projects depends on another project which is not part of the solution.
Just to show the major players in this case, and a simple way to reproduce it:
solution contains ExeProject and MainDllProject , MainDllProject depends on SubDllProject which is not part of the solution (but in the same hierarchy on the file system). ExeProject depends on MainDllProjectClass1 of MainDllProject (that class does not depend on SubDllProject ; only MainDllProjectClass2 depends on SubDllProject , but it is not used by ExeProject nor MainDllProjectClass1 ):
Solution
ExeProject
Form1 (depends on MainDllProject.MainDllProjectClass1)
MainDllProject
MainDllProjectClass1
MainDllProjectClass2 (depends on SubDllProject.SubDllProjectClass)
Not part of the solution
SubDllProject
SubDllProjectClass
When the solution is built with Visual Studio 2010, it fails: MainDllProject cannot be built because SubDllProject cannot be found.
When the solution is built with msbuild, the build succeeds. Strangely, the debug version of SubDllProject is built despite the parameter /p:Configuration=Release.
The log file for msbuild is some 374 kB, do you have some hints how to analyse it? I want to understand why it builds SubDllProject at all, why it is the debug version, and evetually how to prevent it from being built when not referenced (I want the the solution to contain all referenced projects, and when a dependency was forgotten, I want to see an error message).
Note: this case is similar to http://stackoverflow.com/questions/12836023/visual-studio-build-non-dependent-projects-in-solution[^], but quite the other way round...
I understand from http://blogs.msdn.com/b/visualstudio/archive/2010/12/21/incorrect-solution-build-ordering-when-using-msbuild-exe.aspx[^] that msbuild translates the sln file into its own format - but the sln.metaproj file does not show any reference to SubDllProject either.
|
|
|
|
|
You might have better luck asking in this[^] forum.
|
|
|
|
|
Hey CP,
Getting text from one form to another is no problem. But I am having issues showing data from a ComboBox from form1 to display as text in form 2. Alright let's jump right into my example.
string instText = comboInst.GetItemText(comboInst.SelectedItem);
string folder = instText.Substring(0, 4);
comboInst is a combo box that has a list of items that is pulled from a directory. All items have a leading 4 digits that I use a lot in form1. But I can't get those 4 values for the life of me to show even in a messagebox on form 2. It just shows blank when using methods that pull information from a textBox.Text.
I need to be able to use both instText and folder strings in other forms.
Anyone got any ideas? The example I used is located on stackOverflow:
[^]
Thanks!
|
|
|
|
|
If you want to get the selected Item value, you can directly get the selected value using the combo.SelectedItem propety.
but thats not the problem here for you.
did you check the contents of instText has the data you selected? have you tried to debug this?
what is the content of instText?? moreover in which method you call these lines?
|
|
|
|
|
Figured it out, dunno how I mucked it up at first, here's how you do it correctly.
my button from form1
private void buttonSched_Click(object sender, EventArgs e)
{
string instText = comboInst.GetItemText(comboInst.SelectedItem);
string folder = instText.Substring(0, 4);
Schedule Open = new Schedule(instText);
Open.Show();
}
Calling is in form2:
public partial class Form2 : Form
{
private string start;
public Form2(string inst)
{
InitializeComponent();
this.start = inst;
}
private void Schedule_Load(object sender, EventArgs e)
{
System.Windows.Forms.MessageBox.Show(start);
}
Quite simple, I know, but I was thinking too much into something that didn't really need that deep of thought. Thanks for the looks! Hope this helps someone in the future.
BTW - you can alter the string after it's been called to the new form. I.E.
System.Windows.Forms.MessageBox.Show(start.Substring(0, 4));
This is what I needed the code to do, grab the first 4 characters from the string. Now I can use the string raw, or formatted if I like. Thanks again!
|
|
|
|
|
My small box sends the same byte continuously to the PC across a bluetooth connection.
After successfully receiving about four thousand bytes (give or take a few hundred) no more bytes are seen. I am quite confident that the bytes (a whole lot more than four thousand) continue to be sent well after the stream disappears from the rest of the system.
I am highly suspicious that Windows is somehow, for some reason, not accurately giving these bytes to my app.
My suspicion has been heightened because my external transmitting box continued after I stopped the app. I restarted the app, and I got 941 "left over" bytes, from where, I don't really know (but my external byte generator had been silent for several minutes, so it was no longer sending data).
We then started the small box generating continual data again, and saw the same behavior: 4435 bytes were seen, despite a two minute flood of bytes at 921600 bps.
Here is the receive thread
void RecieveThread()
{
int n;
while (continueRecieving)
{
n = connectorPort.BytesToRead;
byte[] bits = new byte[n];
if (n > 0)
{
connectorPort.Read(bits, 0, n);
}
Write(bits);
}
}
Just in case anyone feels it's important, here is the Write(bits) routine
public void Write(byte[] b)
{
if (writting)
{
for (int i = 0; i < b.Length; i++)
{
storage[sPlace++] = b[i];
pass += b[i].ToString("X2") + " ";
if (sPlace % numericUpDown1.Value == 0)
{
pass += "\r\n";
}
}
}
}
Has anyone previously experienced disappearing bluetooth bytes on a Win7 machine with a C# app ?
|
|
|
|
|
How to use database view with Fluent nhibernate?
How can i recall views that are created manually in database with nhibernate technology or is there any option in Fluent nhibernate that create views directly?
|
|
|
|