|
Hi,
my best guess is you have nested exceptions, and the IOException shown is at
a lower level.
suggestion for verification: temporarily change your catch to catch Exception exc
and print exc.ToString(), it should reveal everything.
|
|
|
|
|
void PropertyTree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)<br />
{<br />
if (((XmlElement)PropertyTree.SelectedItem).Name == "Panel")<br />
{<br />
try<br />
{<br />
SettingsPane.Source = new Uri(((XmlElement)PropertyTree.SelectedItem).GetAttribute("Uri"), UriKind.Relative);<br />
}<br />
catch (Exception exc)<br />
{<br />
MessageBox.Show(exc.ToString());<br />
}<br />
}<br />
<br />
}
... is what I have now. I reproduced the exception and it shows the same IOException again (depending on which TreeViewItem I click on (change selection) and I never did get a MessageBox shown within my catch statement...
Thanks for the quick reply!
|
|
|
|
|
The IOException window you get has a "copy to clipboard" facility;
could you please use it and show all the lines preferarbly formatted
line by line, not just as a wrapping stream).
That should tell us something...
|
|
|
|
|
Hope this is how you wanted it.
System.IO.IOException was unhandled
Message="Cannot locate resource 'pages/customtrackinfo.xaml'."
Source="PresentationFramework"
StackTrace:
at MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access)
at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
at System.IO.Packaging.PackWebResponse.CachedResponse.GetResponseStream()
at System.IO.Packaging.PackWebResponse.GetResponseStream()
at System.IO.Packaging.PackWebResponse.get_ContentType()
at System.Windows.Navigation.BaseUriHelper.GetContentType(WebResponse response)
at System.Windows.Navigation.NavigationService.GetObjectFromResponse(WebRequest request, WebResponse response, Uri destinationUri, Object navState)
at System.Windows.Navigation.NavigationService.DoNavigate(Uri source, NavigationMode f, Object navState)
at System.Windows.Navigation.NavigateQueueItem.Dispatch(Object obj)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at AveSkin.App.Main() in C:\Documents and Settings\DocMARs\My Documents\Visual Studio 2005\Projects\AveSkin2\AveSkin2\obj\Debug\App.g.cs:line 0
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
|
|
|
|
|
Gee, that is a terrible trace.
I noticed Threading.ExceptionWrapper.TryCatchWhen at two distinct locations,
and a Threading.Dispatcher.WndProcHook in between.
Are you just clicking some control ???
Can I assume the following ?
your .NET is 2.0 or better
you never set Control.CheckForIllegalCrossThreadCalls false
your app doesnt have other anomalies
I dont understand, but I would suggest three things:
1.
keep the try-catch(Exception exc) for now
2.
you split the suspicious line in smaller parts, e.g. URI=new URI...
3.
you add the following at the start of the offending method:
Console.WriteLine(Environment.StackTrace);
so that should tell us how you get there.
Good luck.
|
|
|
|
|
Sorry, I should have provided more information...
I'm using .NET Framework 3.0 coding a WPF application.
And I don't know if this has anything to do with it but it might...
In the same if-statement, I had the same try-catch statement with a NullReferenceException in the catch statement but I changed it to IOException when I was getting IOExceptions because I had to change my code in the try block and if the Frame control couldn't find the XAML page it was looking for in the try block, it throws the IOException.
Does this help you?
|
|
|
|
|
Andy Spier wrote: Does this help you?
Not really.
I dont quite understand it; you first were prepared to handle NullRefs, then
decided not to handle them anymore ?
Anyhow, I stand by my recommendation to split the difficult line, and keep
the catch (Exception) for now.
Have been looking at Visual itself; you have some say in which exceptions
get intercepted by Visual, rather than passed on to your app. Have a look
at menu Tools/Options/Debugging/General, first two checkboxes.
I dont pretend to understand it all, first is unchecked (cross appdomain,
I dont use extra appdomains so does not matter), second is checked (enable
assistant). You may want to try different settings and/or read up on what
they mean, then decide what you want.
You also may want to try and run your app outside Visual...
|
|
|
|
|
Forgot to mention: in my experience it is useful to have a try-catch(Exception)
around the Application.Run line in static Main() method too; I typically
show a MessageBox with "fatal error; contact so and so" plus the entire
Exception.ToString()
Furthermore there is an Application.ThreadException thing that I still have
to investigate; you probably should consider that too.
|
|
|
|
|
Best bet:
This is a problem with the VS2005 CTP Tools you're using. Try it with the Orcas beta and see if you get the same result.
|
|
|
|
|
Luc Pattyn:
- I tried a release build outside of Visual Studio.
- Checking those boxes would hide exceptions displayed in VS2005 only, not in my final release.
- There is no real main method in .NET Framework 3.0 (WPF) Applications...
martin_hughes:
- I downloaded and installed the latest beta of Orcas just now, tried it and was able to reproduce the same exception...
*Still awaiting an answer*
I REALLY appreciate your help and care so far guys. Much appreciated!
|
|
|
|
|
I found the solution.
More information for reference at:
MSDN Forums - IOException problems...
The last post (or the answer post) is the solution to this problem.
Briefly, you have to use the NavigationFailed event on your Frame and set e.Handled to true in that event handler to stop the IOException from being thrown.
Then you can write code in result of the navigation failure from there.
Hope this helps anyone having the same problem!
Thanks again for your effort and time in attempting to help me!
It was a mighty confusing problem. I'll know in the future to check for events in certain objects to handle exceptions like these...
~ Doc
|
|
|
|
|
Hi all
i just want to know how to create a wrapper class in c#
because i created dll in 2005 and now i want to use it in 2003 so backward compatibility is not there i want to create a wrapper class and then call it in 2003 version.,.can any one help me what all steps need to be done
Advanced Thanks
Regards
DilipRam
|
|
|
|
|
Thats not really possible, or atleast pretty hard and inefficient to do.
Only one version of the framework can be loaded into a single process at a time. That means you'd have to use either something like an out of process COM server or maybe remoting or something like that.
Either way you'd probably be best off working within the limitations of .Net 1.1 if you want something to be used from 1.1
|
|
|
|
|
Hi thanks for the reply.. i can directly change the 2005 code to 2003 and use the dll for reference..but the think is that i have some additional properties which is in 2005 , i have used and are very important for me.so now when i changed to 2003 these properties are not there and hence it is creating very difficult problems.So i heard that there is way to play with it.we want to create a wrapper class and then call the wrapper class object
but i dont know how to create it..can any one help me on this
Regards
DilipRam
|
|
|
|
|
ramdil wrote: So i heard that there is way to play with it.
Any hints on what you were told might work? :P
As I said there are ways but they are inefficient and not a very good idea at all.
ramdil wrote: very difficult problems
It can be more akward to use 1.1 under 2003, but I wouldn't say it creates very difficult problems. Most of the time it just means a little more typing.
What is it that your doing in .Net 2.0 that is so vital and you can't do in 1.1?
|
|
|
|
|
When i searched the net, some where i saw that only way to work around with this type of issue is to create wrapper class but i dont how to work around it...
Regards
DilipRam
|
|
|
|
|
Ok I'll try this one last time in simple terms
What is it that you were told to do to work around the issue? Please supply any information you have about it so that we can advise you on it. If its an article then provide the link. If you read it in an atricle didn't the article tell you how to do it?
As far as I, and it seems anyone else around here, knows the only way to do this is not a good way to work. It's not worth it. You shouldn't do it unless you have a very good an important reason to do so.
It's most likely that the article was either suggesting that you use an out of process server somehow and that is not an efficient way to go unless you really have to. It'll kill your performance and introduce plenty of chances for errorsy ou normally wouldn't have. It will hugly increase the complexity of your systems and generally be a bad idea.
If you describe the features that you want to use in 2.0 but can't in 1.1 then maybe people can suggest what you can use instead.
I'm off home now but if you provide the required info and no one has replied by tomorrow I'll jump right on it.
|
|
|
|
|
Thanks for the reply .Any way i have decided to change the dll from 05 to 03 and use the 03 dll.Anyway thanks...
Regards
DilipRam
|
|
|
|
|
|
I have a single form application that runs in the systray. It is an audit trail logger that uses FileSystemWatcher to monitor file events in a directory. I can capture everything that I am looking to capture except when someone logs off the computer.
I tried using the Form1_Closing method, but it doesn't seem to activate when Windows is closing the application when a user logs off or shuts down the computer. Am I missing something?
Here is my code for the Form1_Closing method. I have no code pointing to this method, I just assume it finds the method when the application closes.
private void Form1_Closing(object sender, FormClosedEventArgs e)<br />
<br />
{<br />
MessageBox.Show("Closing Form");<br />
<br />
string _userName = Environment.UserName;<br />
string _date = DateTime.Now.ToString("yyyy-MM-dd-HH:mm:ss");<br />
string _eventType = "Logged Off";<br />
RegistryKey _regKey = Registry.LocalMachine;<br />
RegistryKey _subRegKey = _regKey.OpenSubKey("Software\\LAT_Systray");<br />
string _fileName = Convert.ToString(_subRegKey.GetValue("File_Name"));<br />
<br />
XmlDocument _xmlDoc = new XmlDocument();<br />
<br />
_xmlDoc.Load(_fileName);<br />
<br />
XmlElement _newEvent = _xmlDoc.CreateElement("Event");<br />
<br />
XmlElement _newDateNode = _xmlDoc.CreateElement("EventTime");<br />
_newDateNode.InnerText = _date;<br />
_newEvent.AppendChild(_newDateNode);<br />
<br />
XmlElement _newUserNode = _xmlDoc.CreateElement("UserName");<br />
_newUserNode.InnerText = Environment.UserName;<br />
_newEvent.AppendChild(_newUserNode);<br />
<br />
XmlElement _newTypeNode = _xmlDoc.CreateElement("EventType");<br />
_newTypeNode.InnerText = _eventType;<br />
_newEvent.AppendChild(_newTypeNode);<br />
<br />
_xmlDoc.DocumentElement.InsertAfter(_newEvent, _xmlDoc.DocumentElement.LastChild);<br />
<br />
FileStream _fsxml = new FileStream(_fileName, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);<br />
_xmlDoc.Save(_fsxml);<br />
_fsxml.Close();<br />
<br />
}
Any help is greatly appreciated as you know.
Jeff
IT by necessity only
|
|
|
|
|
Did you look at SystemEvents class ?
|
|
|
|
|
What am I looking for in the SystemEvents Class? SessionEnding? And how would I use it?
Jeff
|
|
|
|
|
eb38335 wrote: SessionEnding
Yes.
In some discussions I read, it was stated that OnClosing does not always work
reliably. IIRC they claimed one should try using OnClosing, OnFormClosing and
SessionEnding; they probably each would call a single method that could handle
all kinds of exit scenarios.
It is my guess logoff will first generate a SessionEnding event, and
later on tries to close the forms, but may fail to do so, e.g. because
its time is limited, or for some reason it just decides to kill the processes.
Hope this helps.
|
|
|
|
|
I have downloaded the program Instant_Messenger_src .But i am little confused hoe to run that and how to add new client into that application and how to do IM with multiple clients?
Plz help me.
|
|
|
|
|
Please don't spam the entire site, just ask the right person, in the right place.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|