Click here to Skip to main content
15,889,403 members
Home / Discussions / C#
   

C#

 
QuestionHow to get the directory (folder) on which user has done right click Pin
Abhishek Kulkarni23-Feb-09 6:52
Abhishek Kulkarni23-Feb-09 6:52 
AnswerRe: How to get the directory (folder) on which user has done right click Pin
0x3c023-Feb-09 7:44
0x3c023-Feb-09 7:44 
AnswerRe: How to get the directory (folder) on which user has done right click Pin
Luc Pattyn23-Feb-09 8:16
sitebuilderLuc Pattyn23-Feb-09 8:16 
GeneralRe: How to get the directory (folder) on which user has done right click Pin
Abhishek Kulkarni23-Feb-09 18:31
Abhishek Kulkarni23-Feb-09 18:31 
Question[Message Deleted] Pin
muhammadafsal23-Feb-09 6:30
muhammadafsal23-Feb-09 6:30 
AnswerRe: Hello ,Brothers ,hav you know any error priventig codes in asp.net or c#? Pin
EliottA23-Feb-09 7:24
EliottA23-Feb-09 7:24 
QuestionAdobe PDF component on MDI form Pin
RobScripta23-Feb-09 5:18
professionalRobScripta23-Feb-09 5:18 
QuestionQI for IEnumVARIANT failed on the unmanaged server Pin
IGilham23-Feb-09 4:06
IGilham23-Feb-09 4:06 
Hi all,

I have encountered a rather nasty bug that I have no idea how to fix. I'm getting this exception when trying to create a foreach loop on a COM object. The type I am using for my variable is an interface.

For clarity, here is the basic structure of the code. I am using hte information stored in the individual messages to build a log of the operations performed by my program, which is a batch file verification tool.

foreach (KeyValuePair<fileinfo,> kvp in messages)<br />
{<br />
	foreach (IMessage msg in kvp.Value)		// Exception thrown here most of the time<br />
	{<br />
		// ...<br />
	}<br />
}


The exception is thrown on the cast to IMessage in the second loop. I have tried casting to object as well but get the same error. I have also tried avoiding the foreach loop and working with GetEnumerator() directly (not generic), but the GetEnumerator method fails with the same exception.

Occasionaly, the loop will succeed in the cast, but I get even more obtuse exceptions thrown when I try to use the object. This happens seemingly at random. The exceptions are generally something to do with an unrecognised HRESULT or an unavailable RPC server connection, which makes no sense to me, as the application is stand-alone and does not require net access.

The strangest thing for me is that the code actually works in an older version of the program and there have been minimal changes to the class since then. If anything, it has become simpler to allow me to integrate it with other components and a log viewer.

I have found a proposed solutions on the Internet to import some keys to the registry, but I already have those keys in the correct location, so my problem appears to be different. I have never used InstallShield on this machine, so that can't have corrupted my settings as far as I can tell.

Also perplexing is how my primitive error handling code fails to work, where it once did. I get a null reference after the ErrorPage has been created when calling NavigationService.Navigate.

catch (Exception ex)<br />
{<br />
	//application crash<br />
	Debug.WriteLine("Fatal Error Encountered\n\n {0}", ex.Message);<br />
	ErrorPage ep = new ErrorPage(ex);<br />
	this.NavigationService.Navigate(ep);<br />
	IsUIEnabled = true;<br />
}


I'm at a bit of a loss on this. Can anyone help?

.Net 3.5 SP1, Windows XP SP3, Visual Studio 2008 SP1 with a later patch that fixed the intellisense for xaml
QuestionPrintDocument.print StartPrintCall not issued problem Pin
sroliki23-Feb-09 3:28
sroliki23-Feb-09 3:28 
QuestionDatagridview beginners question Pin
Priya Prk23-Feb-09 3:23
Priya Prk23-Feb-09 3:23 
AnswerRe: Datagridview beginners question Pin
Ennis Ray Lynch, Jr.23-Feb-09 3:26
Ennis Ray Lynch, Jr.23-Feb-09 3:26 
GeneralRe: Datagridview beginners question Pin
Priya Prk23-Feb-09 3:50
Priya Prk23-Feb-09 3:50 
GeneralRe: Datagridview beginners question Pin
Ennis Ray Lynch, Jr.23-Feb-09 3:56
Ennis Ray Lynch, Jr.23-Feb-09 3:56 
GeneralRe: Datagridview beginners question Pin
Priya Prk23-Feb-09 4:02
Priya Prk23-Feb-09 4:02 
GeneralRe: Datagridview beginners question Pin
Ennis Ray Lynch, Jr.23-Feb-09 4:07
Ennis Ray Lynch, Jr.23-Feb-09 4:07 
GeneralRe: Datagridview beginners question Pin
Priya Prk23-Feb-09 4:34
Priya Prk23-Feb-09 4:34 
QuestionTelephony Application Pin
smilerP23-Feb-09 3:23
smilerP23-Feb-09 3:23 
AnswerRe: Telephony Application Pin
EliottA23-Feb-09 3:25
EliottA23-Feb-09 3:25 
AnswerRe: Telephony Application Pin
Deresen23-Feb-09 3:30
Deresen23-Feb-09 3:30 
AnswerRe: Telephony Application Pin
Dave Kreskowiak23-Feb-09 5:05
mveDave Kreskowiak23-Feb-09 5:05 
AnswerRe: Telephony Application Pin
Nagy Vilmos23-Feb-09 5:32
professionalNagy Vilmos23-Feb-09 5:32 
RantRe: Telephony Application Pin
Smithers-Jones23-Feb-09 7:33
Smithers-Jones23-Feb-09 7:33 
Questionhow to drag grop in c#.net by usin text not panel or picturebox Pin
poonam jagdale23-Feb-09 3:20
poonam jagdale23-Feb-09 3:20 
AnswerRe: how to drag grop in c#.net by usin text not panel or picturebox Pin
EliottA23-Feb-09 3:21
EliottA23-Feb-09 3:21 
GeneralRe: how to drag grop in c#.net by usin text not panel or picturebox Pin
Ennis Ray Lynch, Jr.23-Feb-09 3:24
Ennis Ray Lynch, Jr.23-Feb-09 3:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.