|
I would guess that accessing the Process.MainModule property for that process is throwing the exception, something that should be checked for in your code (accessing that property can throw three possible exceptions).
Mark Salsbery
|
|
|
|
|
Hello everyone,
Do you know how to simulate in C#, a VB6 Activex EXE Standalone application which exposes a com visible object (IDispatch wrapper class) already instanced in the 'activex exe like' c# application? The clients accessing it via creatobject / getobject will always get a reference on this object.
This does not seem to be so straight forward as I experimented in vb.net. Is it related to .net interop ?
If I understand well, the best way will be to expose a .NET Remoting object (application life time) then creating a COM interop class library which will be used like a tunnel between the two communication solutions. Is it the only solution ?
Any inputs you could share for this are really welcome ?
Thank you so much in advance.
|
|
|
|
|
|
Meanwhile I found a hack, not the real solution I want.
I created my own TabControl , and replaced the TabPages property, such that my own TabPages property will be linked to my editor:
public class MyTabControl : TabControl
{
public MyTabControl() : base() { }
[Editor(typeof(MyTabPageCollectionEditor), typeof(System.Drawing.Design.UITypeEditor))]
public new TabPageCollection TabPages
{
get { return base.TabPages; }
}
}
But that means that I'd have to replace all TabControl s with MyTabControl ...
I'd really prefer a solution like the one described at StackOverflow.
Perhaps you can provide some further ideas.
|
|
|
|
|
Hi all
When creating COM dll from C# i get TLB file.
All enums in the file get a prefix of the enum name
is therea way to remove the prefix?
public enum OPTIONS
{
Zoom = -1,
FitWindow,
FitWidth,
FitHeight,
Actual
}
OPTIONS
{
OPTIONS_Zoom = -1,
OPTIONS_FitWindow = 0,
OPTIONS_FitWidth = 1,
OPTIONS_FitHeight = 2,
OPTIONS_Actual = 3
};
Have a nice Day
|
|
|
|
|
There is, but you're not going to be keen on how much work it is. Anyway, if you want to do this you need to follow the steps in this[^] blog.
|
|
|
|
|
Thanks - i red this before
I was hoping for an easier way...
Have a nice Day
|
|
|
|
|
liqnit wrote: I was hoping for an easier way...
Nope. Sorry.
|
|
|
|
|
I can confirm that that procedure is as easy as it gets.
|
|
|
|
|
|
Im a java developer, new in C#. Im developing a program using C# that saves records of consultations made at a cancer specialised clinic. The user selects a vaccine name, patient, etc. name from records retrived from database and has to get respective ids and use them to update the consultation table in the same database as foreign keys. This is the code that I have, please let me know what I am doing wrong
private void btnSubmit_Click(object sender, EventArgs e)
{
DataSet dataSet = new DataSet();
DataSet vdataSet = new DataSet();
DataSet udataSet = new DataSet();
OleDbCommand cmd = conn.CreateCommand();
OleDbCommand cmdd = conn.CreateCommand();
OleDbCommand com = conn.CreateCommand();
OleDbCommand dbc = conn.CreateCommand();
TextBox patID = new TextBox();
TextBox vacID = new TextBox();
TextBox useID = new TextBox();
patID.Visible = false;
vacID.Visible = false;
useID.Visible = false;
cmd.CommandText = "SELECT patientID FROM patient WHERE fName = '" + cbPatient.GetItemText(cbPatient.SelectedItem) + "'";
cmdd.CommandText = "SELECT vaccineID FROM vaccine WHERE vName = '" + listVaccine.GetItemText(listVaccine.SelectedItem) + "'";
com.CommandText = "SELECT userID FROM userDetails WHERE username = '" + cbUserName.GetItemText(cbUserName.SelectedItem) + "'";
dbc.CommandText = "INSERT INTO Consultation (date, patientID, vaccineID, userID, diagnosis) VALUES ('" + DateTime.Now.ToString() + "', " + patID.Text + ", " + vacID.Text + ", " + useID.Text + ", '" + cbDiagnosis.SelectedItem + "')";
conn.Open();
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(cmd);
OleDbDataAdapter vdataAdapter = new OleDbDataAdapter(cmdd);
OleDbDataAdapter udataAdapter = new OleDbDataAdapter(com);
OleDbDataAdapter da = new OleDbDataAdapter(dbc);
dataAdapter.Fill(dataSet);
vdataAdapter.Fill(vdataSet);
udataAdapter.Fill(udataSet);
patID.Text = dataSet.Tables[0].Rows[0].ItemArray[0].ToString();
vacID.Text = vdataSet.Tables[0].Rows[0].ItemArray[0].ToString();
useID.Text = udataSet.Tables[0].Rows[0].ItemArray[0].ToString();
MessageBox.Show(patID.Text);
MessageBox.Show(vacID.Text);
MessageBox.Show(useID.Text);
dbc.ExecuteNonQuery();
conn.Close();
MessageBox.Show("Entry added!");
}
|
|
|
|
|
1. Please use <pre> tags round your code, and indentation in it, so that it is readable.
2. Please explain what problem you are having with the above code.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
That looks like it should work (assuming that that insert statement matches the schema of the table you're trying to put stuff into), though having retrieved the three tables you probably want to set them as DataSource on something. What problem are you having?
You should use parameterised queries though, as they're better in several ways and avoid the possibility of a SQL injection attack (which would appear to be present here).
|
|
|
|
|
Print your SQL string before you use them.
You need to expect that exceptions will occur and you must provide a mechanism for dealing with them in some way.
I doubt that you are correctly constructing the value for 'date'.
|
|
|
|
|
Is any Linked Open data projects in C#, ASP.Net available for learning RDF/XML?
|
|
|
|
|
Don't just post the same question in Q&A and the forums - pick one and stick to it.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
I need to change the location of where a database file is located in a C#.net 2008 desktop application, but I am hacing problems. When stepping through the code, I find that I need to change a 'settings.settings' file. Bascially I need to be able to access the properties in some kind of a designer and I jhave not be able to do that. Would you have an idea of where I can obtain the directions to access the settings.settings file?
|
|
|
|
|
Assuming that you are using Visual Studio then use your mouse to right-click on the project name and select Properties. This will open a project properties tab and the settings selector is half way down on the left. Select the relevant item and edit as required.
Alternatively check the Properties folder in your project directory and you will find the file there. It's an XML file that you can edit with your favourite editor.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I have written the following
List<Project> UserProjects = ...
string domain = cbxDomain.SelectedValue.ToString();
HashSet<string> itemsToShow = new HashSet<string>();
And I was wondering which of the two snippets below people prefer
A) Use a Predicate
foreach (Project p in UserProjects.FindAll(delegate(Project x){return x.DomainName.Equals(domain);}))
{
itemsToShow.Add(p.ProjectName);
}
Or
B) Nested if
foreach (Project p in UserProjects)
{
if (p.DomainName.Equals(domain))
{
itemsToShow.Add(p.ProjectName);
}
}
0If you haven't used HashSet before, it is basically a List that sort of behaves like a Dictionary in that doesn't allow duplicates, but doesn't throw an exception if you try and add a duplicate. (I know that's an over simplification, - see MSDN[^] for full description)
|
|
|
|
|
Given the choices, the second. FindAll with an old-style anonymous function is a bit ugly in my opinion. Do you have the option of replacing that with a LINQ query?
|
|
|
|
|
I personally would go with the second choice for the sake of readability.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
The latter. But why are you usnig .Equals ?
|
|
|
|
|
I'll join the crowd and prefer the latter for its readability; the former isn't bringing anything IMO.
|
|
|
|
|
why not just use:
if (!itemsToShow.Contains(p.ProjectName))
itemsToShow.Add(p.ProjectName);
gets rid of the foreach and the ugly LINQ statement.
Please stop using LINQ for every little thing... the performance hit you take is big . People who use LINQ all over there code often find themselves re-writting slow chunks down the road.
|
|
|
|
|
While the second part is true,
SledgeHammer01 wrote: why not just use: [something]
Because it does something entirely different.
|
|
|
|