|
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)
{<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 />
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
|
|
|
|
|
Hi
I have a C# program that runs several threads. each thread prints a documents to a specific print
queue using a PrintDocument.print method. the problem is that after some minutes the application gets
a StartPrintCall not issued exception.
I am trying to locate some info regarding to what is causing this exception and how to solve it.
any help will be great!!!
10'x
|
|
|
|
|
Hi guys,
I m using a datagridview to show some data from sql server database.
I made the rows in designer and bounded the datagridview to my database.
It works great except one thing:
the datagridview gets new columns according the columns to datatable. It doesn't use the columns that i alread made.
I tried 'SELECT ColumnName as datagridViewColumnName' bud still not working.
Anyone a idea how to fix this?
Thanks a lot.
|
|
|
|
|
There is a setting to auto generate columns, turn that off. Then make sure each column is correctly bound.
Need custom software developed? I do C# development and consulting all over the United States.
If you don't ask questions the answers won't stand in your way.
Doing a job is like selecting a mule, you can't choose just the front half xor the back half so when you ask me to do a job don't expect me to do it half-assed.
|
|
|
|
|
Thanks for reply Ennis,
I set the autogenerate columns, bud now can't see the data in the datagridview. I have 3 records in my table. The grid shows 3 empty rows
|
|
|
|
|
Excellent. Now you just need to bind the rows correctly. Since you are using the designer there should be a property for DataItem with the column definitions. Set that to the column name you want to bind to. (I am guessing at the names because I haven't used Databinding in years but all of them work about the same)
Need custom software developed? I do C# development and consulting all over the United States.
If you don't ask questions the answers won't stand in your way.
Doing a job is like selecting a mule, you can't choose just the front half xor the back half so when you ask me to do a job don't expect me to do it half-assed.
|
|
|
|
|
I did this to look at the code, i exactlly copied and paste the names of the columns of the datagridview into the query. Still 3 empty rows:
SqlConnection mycon1 = new SqlConnection(connString);
SqlCommand mycom1 = new SqlCommand();
mycom1.CommandText = "SELECT CONTR_NR as contrId, " +
" CONTR_PROCOUNT as contrProCount, CONTR_TOTPRICE as contrTotPrice FROM Contracts WHERE CONTR_CU_ID='" + custNr + "' ";
myda1 = new SqlDataAdapter(mycom1.CommandText, mycon1);
mycb = new SqlCommandBuilder(myda1);
mydt1 = new DataTable();
myda1.Fill(mydt1);
mybs = new BindingSource();
mybs.DataSource = mydt1;
mf.dgvContr.DataSource = mybs;
And im sure that i have 3 records in my table
|
|
|
|
|
Yes but you have to bind the grid view columns using the data item property. Maybe you have them setup as unbound columns? The visual wizard lets you pick from a list of column names.
Need custom software developed? I do C# development and consulting all over the United States.
If you don't ask questions the answers won't stand in your way.
Doing a job is like selecting a mule, you can't choose just the front half xor the back half so when you ask me to do a job don't expect me to do it half-assed.
|
|
|
|
|
Hi Ennis,
Thanks a lot for your help. It works now
|
|
|
|
|
Please i am working a Telephony application which must be able to dial a given phone number using a Motorola SM56 Data Fax Modem that comes with HP Pavillion dv6000 and play prerecorded .wav or .mp3 file when the handset is picked at the other end.Any help including direct source code in C#,DLL or COM files will be greatly appreciated.Thanks.
|
|
|
|
|
Click my signature for help.
|
|
|
|
|
If you pay us with gold (dollars are soo 2007 and outvalued) we would considder helping you.
If you have problems ask us those.
If you have bugs, the same.
If you would like to have a full functioning app, then pay.
|
|
|
|
|
You're not getting any source code. We'll help you write you own code, but not write it for you. You don't learn anything that way and turning in someone elses work as your own will just... well, it won't be pleasant.
You're need to start looking into a C# wrapper for TAPI3.0.
|
|
|
|
|
I hope this is not for real. I don't knopw for sure the US law (or where ever you really are), but in the UK un-attended dialers as you are describing are illegal. Lucky for you that your brain doesn't work otherwise you'd be a criminal.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Sounds like SPIT (Spam over Internet Telephony) to me.
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
|
|
I don't know it is actually easy to understand what he wants. I think the worst question ever would have to be completely unintelligible. Lack of due diligence is de rigueur here.
Need custom software developed? I do C# development and consulting all over the United States.
If you don't ask questions the answers won't stand in your way.
Doing a job is like selecting a mule, you can't choose just the front half xor the back half so when you ask me to do a job don't expect me to do it half-assed.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: it is actually easy to understand
Okay Mr Clever-Clogs, how do you drag grop?
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I want a source code for reading bits from the lines of parallel port.I already have two sensors that give output signals of about +5v and want to read these sensor outputs independently when either is triggered.I figured that connecting the sens or outputs to the input lines of a parallel port will do and would like to order a (usb to parallel) adapter since i do not have a parallel port on my HP pavillion dv6000 laptop.Will the PC recognize the (parallel to usb) adapter as usb or parallel and if it can see it as parallel i need C# codes to help read the sensor outputs.Please help me because it's very urgent.
|
|
|
|
|
smilerP wrote: I want a source code
Here you go:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
}
}
}
Kristian Sixhoej
"You can always become better." - Tiger Woods
|
|
|
|
|
smilerP wrote: Please help me because it's very urgent.
Only if you tell me how urgent it really is.
|
|
|
|
|
Hi,
you can easily observe and control the circa 5 control lines of an RS232C port (directly attached, or USB-to-RS232C) using the SerialPort class available since .NET 2.0 (mind you, through USB the maximum speed for operating the control lines will be less).
I haven't seen anything I would trust to run on recent Windows versions for parallel ports.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:33 AM
|
|
|
|
|
|
what is the function of [STAThread] in c#
the quieter u become more u hear
|
|
|
|