|
Is wrapping every C++ classes in C# classes the only way to allow interopability between a C# application and a C++ DLL?
|
|
|
|
|
Hi,
I am using Visual Studio 2005 Beta 2 to create a 64bit application. The problem is that i have a com component that i need to reference from my c# application. I cannot add a reference to the com component. Basically, my 64 bit com object does not show up in the list of com components(it registers successfully) under the add reference tab and when i browse for the com component, trying to add it results in an error.
Has anyone run into this problem? Any suggestions?
Thanks.
|
|
|
|
|
I VC++ if you creaed a function to do a specific thing you first referenced it in the header file then added to the cpp file.
Example:
Header:
int myFunc();
CPP:
int CMyClassDLG::myFinc()
{
}
So in C# I created this dialog based app. I added a function to get all the nic listed on my machine. Called the function GetNics(). How do I call this?
When I try and call this in Main() is says something about
"C:\My Documents\Visual Studio Projects\MyNetwork\Form1.cs(111): An object reference is required for the nonstatic field, method, or property 'MyNetwork.Form1.GetNics()'"
So do I need to create a new class for each new function I want to do?
Can someone point me in the right direction?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Okay I think I may have found it. Can I not call any functions in the Main portion of my code? What I was doing was trying to load up a dropdown list when the form first loaded. I found out that by double clicking on the form created a function call Form1_Load in whick I could call my functions. So is this how I am supposed to do it?
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
In the Main function you can only call other static functions in that class. Otherwise you must put your functions in a separate class and then new the class in Main and then call the function on that class.
Kevin
|
|
|
|
|
If you want to call the GetNics() method in the class it beongs to, you just call it as GetNics() , if you call it outside the class you have to create an instance of the owner class and then call it as 'instanceNameHere.GetNics()'
For only static methods you can use ClassNameHere.MethodNameHere()
Good luck.
|
|
|
|
|
I'm not sure what you mean by this,
Utku KAYA wrote:
'instanceNameHere.GetNics()'
Here is my code:
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
MyNetwork.LoadNics(); <br />
<br />
}<br />
<br />
private void Form1_Load(object sender, System.EventArgs e)<br />
{<br />
LoadNics();<br />
}<br />
<br />
private void LoadNics()<br />
{<br />
ArrayList nicName = WMIHelper.GetNics();<br />
<br />
NICScb.Items.Clear();<br />
foreach ( String name in nicName)<br />
{<br />
NICScb.Items.Add(name);<br />
}<br />
if (NICScb.Items.Count > 0)<br />
{<br />
NICScb.SelectedIndex = 0;<br />
}<br />
<br />
}<br />
<br />
}<br />
I still get an error in the main function. I read that the main function does not belong to the object, so I see what you mean by referencing the instance. But it still errors out. Can you explain some more for me?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
By placing the LoadNics() method into the FormLoad event, it means that every time the forms get created (or, if u prefer, the class gets intantiated) the LoadNics() method will be executed.
Just cut & paste the LoadNics() method call from the FormLoad event into the Main() method of your class. So your new Main() class would consist something like:
static void Main()
{
Application.Run(new Form1());
LoadNics();
}
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
|
That does not work. I've tried it several times. The problem is that while Main belongs to the class rather than any particular object of the class, my LodNic() function belongs to a particular object of the class...this is why it is not a static function, and why it errors out.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Greeting,
i am working on a Project which uses Database for almost information, that is mostly it is concerned with view of information stored in Database.
The current approach i have with me is to open Database ( MS -Access ) , apply the desired SQL command, and read from OleDbDataReader, but the problem is due to heavy use, application seems to be slow down !
Another idea i have with me is, to once get all information in DataSet , and access it later , my question here is, can i apply all commands which i have been using to get data from original database ? i actually want to know is it really possible ?
What i think is DataSet works as a Virtual Database ? am i right ?
If someone can help, i will really be grateful. It will be pleased to have a detailed answer.
Regards
Yahya
muhammad.yahya@gmail.com
|
|
|
|
|
What dataset does it to make a local copy of some tables (You can make it all the database),
That is why it's called disconnected ,cuz it stores this copy in the ds and then it disconnects from the dataserver or file and then,after all the changes you make to the tables contained in the and then just make your local database copy (With changes) update the original by using the dataadapter class.
|
|
|
|
|
Hi,
I have the following problem:
I have a windows form called <customfunctions>.In the form <customfunctions> I have, among other controls, a textBox called <textboxfunction>, a comboBox called <comboboxuserfunctions> and 2 buttons called <btnsave> and <btnedit>.
In the second form, called "Save" when <btnsave> pressed and "Edit" when <btnedit> pressed, I have only a textBox called <textboxfuncname> and a button <btnok>.
Case 1: When I press <btnsave>
=============================
In the second form:
When pressing <btnok>, I want to take the text in the <textboxfunction> (this would be the function's formula) and the text in the <textboxfuncname> (this would be the name of the function) and add them to <comboboxuserfunctions>.
Case 2: When I press <btnedit>
==============================
In the second form:
When pressing <btnok>, I want to take the text in the <comboboxuserfunctions> put it in the <textboxfuncname>, where it can be changed.
When I pres <btnok> I want the <comboboxuserfunctions> to reflect the changes made, meaning that the funtion has a new name.
The big problem is that I don't know how to transfer data between forms without using IsMDIContainer Property. I don't use this property because I don't know how to make the MDIChild visible (to actually see every control on the MDIChild form).
Please help me !!! I'm in desperate search for help !
I've tried up to now all I could ever think of (obviously not enough) confused:
Cheers to all of you,
Adisor
|
|
|
|
|
This is nice. Have you actually read your own post and tried to make any sense of it? Go ahead, try it now. I'll wait...
Don't enclose anything in < and > brackets unless you want it to be treated as an HTML tag. The workaround is to check the little box under the message window that says "Do not treat <'s as HTML tags" before you click the Submit button.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Sorry I didn't realise that. Here is the previous post this time with all the names in it and no more HTML tags.
Hi,
I have the following problem:
I have a windows form called CustomFunctions .In the form CustomFunctions I have, among other controls, a textBox called textBoxFunction , a comboBox comboBoxUserFunctions called and 2 buttons called btnSave and btnEdit.
In the second form, called "Save" when pressed btnSave and "Edit" when pressed btnEdit, I have only a textBox called textBoxFunctionName and a button btnOk.
Case 1: When in the first form I press btnSave
==============================================
In the second form:
When pressing btnOk, I want to take the text in the textBoxFunction(this would be the function's formula) and the text in the textBoxFunctionName(this would be the name of the function) and add them to comboBoxUserFunctions.
Case 2: When in the first form I press btnSave
==============================================
In the second form:
When pressing btnOk, I want to take the text in the comboBoxUserFunctions and put it in the textBoxFunctionName, where it can be changed.
I want the to reflect comboBoxUserFunctions the changes made, meaning that the funtion I choose to edit has a new name.
The big problem is that I don't know how to transfer data between forms without using IsMDIContainer Property. I don't use this property because I don't know how to make the MDIChild visible (to actually see every control on the MDIChild form). When I tried using this property the MDIChil form appeared as if it were in a bucket: the MDIParent form. I've tried using BringToFront() method but it didn't work.
Please help me !!! I'm in desperate search for help !
I've tried up to now all I could ever think of (obviously not enough)
Cheers to all of you,
Adisor
P.S. Sorry once again for the mistake from the previous post. Thank you for correcting me.
|
|
|
|
|
I didnt totally understand what you are doing, but using form tag to transfer data between different form is a very common practice
|
|
|
|
|
Il y a un problème avec Cause validation que je ne comprends pas
J’ai TextBox avec un événement Validating et quand je ferme la feuille, la fermeture declenche l’événement Validating de TextBox.
J’ai mit la propriété Cause Vlaidation de la feuille en FALSE, mais ça marche toujours pas.
|
|
|
|
|
This is an English speaking board!
You might want to repost this question.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Ok
The problem is the folowing:
I have a TextBox in the form of C#. The Textbox has un event Validating where I do my code. The form is the property CausesValidation = False
I try to close the form with the Top Right X button , and the event Validating of TextBox fire. I want to know why , and how can I close the form whithout firing the TextBox Validating event
Thanks. Merci.
|
|
|
|
|
Bonjour,
C'est un forum anglophone mais je vous reponde votre question.
Si la propriété "CausesValidation" est en TRUE, quand le TextBox est en focus, les événements "Validating" et "Validated" sont declenchés. Si la propriété "CausesValidation" est en FALSE, les événements ne sont declenchés pas.
Je suis heureux de vous aider.
Andy
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|
|
Le problem est justement que quand je freme la feuille avec un propriété CausesValidation = False, l'evenement Validating de TextBox çe declanche quand meme
|
|
|
|
|
Does anyone know how to obtain the GUID for say a version of Excel 2003 ?
I'm building a deployment project and under my launch condition, I need to know if Excel 2003 is there. But as to date, I don't have any luck..
So, perhaps someone can shed me somelight where in the registry should i be looking at...
Stanley
|
|
|
|
|
|
Hi guys. Listen, I've got a problem:
I'm building this email server/client for a school project. I've done pretty much everything, but I've stumbled upon something. So far, I've been testing my application on localhost, so everything worked just fine, but now I've got
problems when trying to send email to an actual email address. Say it's 'abcd@yahoo.com'.
When I click Send, my program crashes. I thought that it was because I was supposed to send to the MX server, not directly to the Yahoo server, so I changed the address to 'abcd@mx1.mail.yahoo.com'. It worked ok until the RCPT TO command, at which point Yahoo's SMTP server says that the address is bad.
So in a nutshell, the problem is this: "How do you actually send email?"
What am I to do? How can I crack this? Can you suggest an alternating route?
Thanx a million.
|
|
|
|
|
Use your school's smtp host to send your mail through. It should work if your protocol is set up correctly...
|
|
|
|