|
airmigjr wrote: Today I work with Java, but I started teaching C# to beginners.
I don't mean to sound negative, but I don't think you should teach C# (yet) if you still have these kind of questions.
That doesn't mean you're a bad programmer, but I think you still lack the thorough .Net knowledge to teach it.
I'm working with .Net for almost 10 year now (since 1.0) and I wouldn't even want to teach it.
|
|
|
|
|
I totally agree with you.
Think! Don't write a line of code unless you absolutely need to.
|
|
|
|
|
You didn't close the startup form. You closed another INSTANCE of Form1.
You should not have used Show to show Form2. You should have used ShowDialog. That way, when Form2 closes, the original instance of Form1 gets control back. Though, the down-side to using this is that Form1 code blocks until Form2 closes.
Form2 form2 = new Form();
this.Hide();
form2.ShowDialog(); ' Blocks until form2 closes
this.Show();
|
|
|
|
|
Very thank's Mr. Kreskowiak. You helped-me very very much!!! Thank's Again!, and Best Regards!
|
|
|
|
|
As far as teaching this class, you and your students are still screwed. You don't have the prerequisite knowledge to teach this stuff. You're just going to be guessing at how things work and the only thing worse that not knowing anything at all about what you're learning is being completely misinformed about what you're learning, and that's the path you're leading these students down.
|
|
|
|
|
This is entirely the wrong way to demonstrate Show/Hide. Multi-form UIs are difficult to get right, and coding up the example that you are using correctly will introduce a whole bunch of concepts (about main forms, the application loop and Program.cs) that are not relevant to the point.
Just have a button on your main form that shows or hides the secondary one.
And why are you creating a new instance each time? Such an elementary misunderstanding of objects and classes indicates that you shouldn't really be teaching people about any OO environment.
|
|
|
|
|
A windows App process will not close until the Main method exits.
And you're creating a new instance of the forms on each button click. What you should ideally be doing is to create a private member of Form2 in Form1 and instantiate it in the Form1's constructor or when it is first used (and vice versa for Form2).
|
|
|
|
|
Hi All,
I was developed a c# windows application and now I want to create a setup package for it that contains the SQL SERVER and .NetFramework and the application itself.
please help me how to create this package and how to handle the windows type and bits like windows 7, vista, 64 or 32 bit.
Thanks All
|
|
|
|
|
Look here[^]. zead wrote:
I was developed a c# windows application and now I want to create a setup package for it that contains the SQL SERVER and .NetFramework and the application itself. I don't think you can package SQL server with your application. Not sure if the license allows to do this.
|
|
|
|
|
I wrote one .net c++ dll,and reference it in an c# winform program .Prompt the following error:
title: BadImageFormatException was unhandled
content:
Could not load file or assembly “CppDll, Version=1.0.4798.31848, Culture=neutral, PublicKeyToken=null”or one of its dependencies.
the Default cpu settings is anycpu,when i change it to x64,the result is the same.but when i change it to x86 it can work well.
This is a very simple test example code:
part dll code:
namespace CppDll {
public ref class Class1
{
};
}
part exe code:
public Form1()
{
CppDll.Class1 cls = new CppDll.Class1();
InitializeComponent();
}
|
|
|
|
|
peter462 wrote:
the Default cpu settings is anycpu,when i change it to x64,the result is the same.but when i change it to x86 it can work well. Where are you changing? In the C# project?
|
|
|
|
|
It doesn't work because you compiled your C++ .DLL as 32-bit. You cannot mix 32- and 64-bit code in the same process.
Either recompile your .DLL as 64-bit or go into your C# project properties and target x86 (32-bit) to force your C# code to run as 32-bit only.
|
|
|
|
|
This is why the default setting isn't Any CPU anymore.
|
|
|
|
|
Hello friend!!
I will required the whole static text present on external application's input box or message box.
For example consider Microsoft word as external application which is password protected.
Suppose my file name is "Demo.docx", when I clicked on this file the "password" input box is opened as i have already mentioned my file is password protected.
The "Password" input box will contain static information message as follows:
Enter the password to open file "C:\...\sham\desktop\Demo.docx"
So my requirement is to getting this static message present on external application's input box or message box.
Is there any way to read out this message programmatically??
|
|
|
|
|
sham bhand wrote:
Is there any way to read out this message programmatically?? I don't think there is way to do this completly using .NET classes. You have to work with native windows functions to do this. The idea is
1 - Get the window handle for the textbox you need to read. You can use FindWindow()[^] or FindWindowEx[^] to get a window handle.
2 - use SendMessage and send WM_GETTEXT to the handle to get the text.
|
|
|
|
|
Check out the "UI Automation" classes in the .NET framework.
Google "UI Automation C#" to get started.
|
|
|
|
|
Actually I am Beginner To C# and i don't know how to do it can you give me one sample code about this.
|
|
|
|
|
|
Hello. I am trying to get CPU usage using the PerformaceCounter class. I am using the following code which I see everywhere on online tutorials. Still it does not produces the expected result.
PerformanceCounter pc = new PerformanceCounter();
pc.CategoryName = "Processor";
pc.CounterName = "% Processor Time";
pc.InstanceName = "_Total";
long lResult = (long)pc.NextValue();
Now lResult always returns ZERO. Why is it so?
Related Question: I have managed to get the list of CounterName (s) but how do I get the list of InstanceName (s)? (i.e. _Total )
Thanks for any input.
This world is going to explode due to international politics, SOON.
|
|
|
|
|
I working with C# 2008 and 2012 windows applications that need to call different executables.
Are there other ways to call theses processes besides the way I have the code listed below:
Process eProcess1 = new Process();
eProcess1.StartInfo.FileName = strConsoleAppLocation;
Process1_Arguments = " 10 " + kgID;
eRPT_Process1.StartInfo.Arguments = Process1_Arguments;
eRPT_Process1.Start();
If there are other ways to start a process, can you write the code and/or point me to a reference that
will display other ways that an executable can be run from C# code?
|
|
|
|
|
You could manually invoke ShellExecuteEx , but that'd be more complicated without giving much advantages (if any).
I'm curious, why are you looking for an alternative?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
This application just went into production. I am tryuing to determine if 'extra' processes can be started with other kinds of C# statements in the code.
|
|
|
|
|
classy_dog wrote: I am tryuing to determine if 'extra' processes can be started with other kinds of C# statements in the code.
Search your code for the Proces class.
If there's a static class somewhere, loaded once every full moon, with some "unmanaged resources", you might have the same problem. Another way of executing code would be by compiling it on the fly, and to generate the required call to the Proces-class on demand, from an encrypted string.
Still curious what you're looking for, might help in giving a more useful answer.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
 I am getting the following error message on the production server:
Process 9528 (\Device\HarddiskVolume2\Program Files (x86)\red\sampleclient.exe) has opened key \REGISTRY\USER\S-1-5-21-11-222-333\Software\Microsoft\SystemCertificates\TrustedP eople
Process 8880 (\Device\HarddiskVolume2\Program Files (x86)\red\sampleclient.exe) has opened key \REGISTRY\USER\S-1-5-21-11-222-333\Software\Microsoft\SystemCertificates\TrustedP eople
Process 9528 (\Device\HarddiskVolume2\Program Files (x86)\red\sampleclient.exe) has opened key \REGISTRY\USER\S-1-5-21-11-222-333\Software\Microsoft\SystemCertificates\My
Process 8880 (\Device\HarddiskVolume2\Program Files (x86)\red\sampleclient.exe) has opened key \REGISTRY\USER\S-1-5-21-11-222-333\Software\Microsoft\SystemCertificates\My
Process 9528 (\Device\HarddiskVolume2\Program Files (x86)\red\sampleclient.exe) has opened key \REGISTRY\USER\S-1-5-21-11-222-333\Software\Microsoft\SystemCertificates\Disallow ed
Process 8880 (\Device\HarddiskVolume2\Program Files (x86)\red\sampleclient.exe) has opened key \REGISTRY\USER\S-1-5-21-11-222-333\Software\Microsoft\SystemCertificates\Disallow ed
This keeps processes running on the production server. The production server does not release reources.
I am tyring to figure out what could be causing this problem.
This application connects to a web service. The code I am using was initially obtainexd from the company that werote the web service.
There are *.xsd files in a proxy attached to this code I am running.
Thus do you think I need to contact the company with the web service to see what has changed on their side?
|
|
|
|
|
classy_dog wrote: The production server does not release reources.
How does that relate to the messages you posted? And how are you measuring those?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|