|
To do it properly you need to use:
using System.CodeDom;
using System.CodeDom.Compiler;
you can use the methods in these classes to serialize your form and generate .cs and .resx files for it and also a .dll file.
It is not easy.
|
|
|
|
|
I have a application that neds to have a listening socket thread. I've created the worker thread but I'm not sure how to access my Windows Form controls from with in the thread. I'l like to update a TextBox with text from within the worker thread.
|
|
|
|
|
|
And just to avoid any possible problems, pay attention to how you use Control.Invoke from the worker thread in that article Mike gave you. This is a common mistake. Updating the UI from thread besides the main thread has "undefined" behavior. Sometimes it works, sometimes it doesn't, and sometimes it screws up your message pump (or, loop) so that some messages aren't handled correctly!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Okay here is what the problemo is ..
I am using MDI ... so i have this modal dialog box which opens up when the user clicks on a menuitem ... The person needs to enter some info into the dialog and click okay after that the values are passed to another form that is a MDI Child to the main form ... The problem is when the user clicks the close button the programm crashes ... I know why it does that because on the Okay button i inserted the code in the closing event so when the person closes the modal dialog with out filling anyhting in it .. it crashes which makes sence ...
I cant find a way to get around this problem ... The programm is a video lib managment system ... the modal dialog takes in the users code and opens the renting form ... Which is the mdi child ..
let me post the code it might help
<br />
CustomerCodeDialog cust == new CustomerCodeDialog();<br />
cd.ShowDialog();<br />
<br />
string customer_code = cust.getCustomerCode();
string custoerm_name = cust.getCustomerName();<br />
<br />
issueWindow issue = new isuueWindow();<br />
issueWindow.MdiParent = this;<br />
issueWindow.Show();<br />
And please i cant find a good tutorials on MDI form for C# on codeProject or any other web site .. any links would help me alot...
Sorry my wnglish isnt that great ...
Thanks
DaIn
|
|
|
|
|
If the inputs are validating, crashing the problem makes sense?!
You need to validate your inputs and gracefully warn the user or exit, depending on the circumstances (exiting, like in the case of 3 invalid password attempts or something). Crashing your program is not acceptable for clients!
Besides, never trust user input. Always validate input, even if it's just checking to see if input was provided. You should also put such commands in try-catch blocks so execeptions are caught and handled correctly.
One more thing, when using modal dialogs, you need to dispose them when you're done. So, after you get done grabbing values form your cust variable, call cust.Dispose() . Otherwise, the memory for the modal dialog (actually, this has to do with native handles used to display the modal dialog) won't be freed. This also helps keeps the memory footprint of your app down.
As far as MDI tutorials, I can't recommend any, but you should read the .NET SDK Documentation for the MDI-related methods and properties, such as Form.MdiChildren , Form.MdiParent , Menu.MergeMenu , and the like. It's not great, but it might give you a little more insight to some specific questions you might have. Otherwise, just ask the forum!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Oh, and as far as validating inputs, it's common practice to not let the user close the dialog until they've either canceled the dialog or enter the valid values. You should also get a DialogResult back from the ShowDialog call so you know what the user did:
DialogResult result = cust.ShowDialog();
if (result != DialogResult.OK) return; Or something like that. Then, in your form, make sure your OK and Cancel buttons have the right DialogResult property set (OK or Cancel), and that your form specifies the Form.AcceptButton and Form.CancelButton .
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks alot for the help
|
|
|
|
|
i need to develop on a network server here at work, but we can't get it setup right.
according to microsoft, you either need to be logged into the network as the same user as the asp.net process runs under, ... or ... logged in as an administrator of the box.
our admin says he can't set me up as admin, and i can not login as the asp.net process.
I am setup in the 'Debug' group on the server, but I still get permission errors.
anyone know any other way i can debug remotely with asp.net ?
|
|
|
|
|
It doesn't really matter which group you're in, so long as you have the debugging privilege (and just because there is a group named 'Debug', it doesn't necessarily mean these privileges have been granted). The priviliges should be configured in the Security snap-in for the computer, DC, or domain. The admin should also make sure that the Local Security Policy for the computer has the privileges assigned. Since domain privileges take precedence over local ones, using the Local Security Policy shows you whether a user or group really will have those privileges.
Second, don't forget to enable debugging in the Web.config file.
Finally, make sure the debugging tools are actually installed on the server. If you install the .NET Framework SDK on the server, I believe this is enough. In the VS.NET setup, there are some additional tools you can install remotely, but I believe these are only for DCOM debugging.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I'm looking for menu code that will allow the user to drag/drop menu items to move them where they want and allow detection of a right click on a menu item.
Any pointers would be appreciated.
|
|
|
|
|
Can anyone help?
I want to code an interface and assign a GUID to it.
public interface IMyInterface
{
}
On the web I found articles that say I should put the interfaces GUID above the interface declaration. But I get an error message saying GUID is not recognised. My using clause has System. So how can I do this?
The reason is in Delphi my objects support interfaces and then by zooming thru a list of objects I can ask if the object supports the interface and if so talk to the object thru that interface.
I have had a good look thru my books and internet articles but cannot find any really good info.
If there is a new way to do this I would also be interested.
Thanks
Luke
|
|
|
|
|
Yes, you do use the GuidAttribute but you must use the right namespace: System.Runtime.InteropServices . You can either include it toward the top with the using statement, or prefix your GuidAttribute (or any class for that matter) with the proper namespace. You must also be referencing the assembly in which the Type contains. I'm only mentioning this so you understand. The System.Runtime.InteropServices.GuidAttribute Type is in the mscorlib.dll assembly, so it is automatically referenced by the compiler (unless it's told otherwise, which is only possible with the command-line compiler).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
is that above the interface declaration
System.Runtime.InteropServices.GuidAttribute["....."]
public interface IMyinterface
{
}
And how can I ask an object if it supports the interface so that I can talk to it soley thru that interface (this is how I would have done it in Delphi)
Cheers
Luke
|
|
|
|
|
No offense meant, but you should probably read the C# specification. Attributes are like so (fully-qualified example):
[System.Runtime.InteropServices.Guid("363EBCCC-5E9A-4e14-8A5D-F0DA44E69EF9")]
public interface IMyInterface
{
{ In C# (and some other languages, but you have to read their specs to find out), you can drop the "Attribute" at the end of attributes. If you want to use properties that aren't in the constructor parameters, fill all the necessary params then use PropertyName=Value , like so:
[MadeUpAttribute("somestring", SomeParam="SomeValue")]
public class SomeClass
{
}
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
No offence taken. I have brought 2 very good reference texts for C# / .NET. My problem is that I professionally program in Delphi. So I know what I want to do but I haven't yet got used to framing the question I want to ask in C# terms to get the answer. But moving to C# has been very easy due to the similar class libraries so I have a head start on my fellow C++ m8s.
Thanks for your help tho.
|
|
|
|
|
My comment wasn't in reference to how you "framed" your question, but rather your syntax. Attributes in C# are enclused in square brackets ([ and ]) and you tried using them for your constructor params, which are always parens (( and )). This is just a simple matter of syntax. While it's true that the syntax (i.e., language) you use to write your code for .NET isn't really so important (knowing how to use and extend the base class library, and how to make your own libraries and applications is more important), you still need to know the syntax of the language you've choosen. I was just pointing out that you should read over the C# language specifications to know exactly what the syntax is - you might even learn a few tricks that aren't always discussed in books (like using the using statement to automatically dispose IDisposable implementations, or to use the same statement to creat a Type alias (especially handy when you have Type collisions, i.e. two different Types with the same name that belong to two or more namespaces you've imported).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Im my opinion, a good example of the uses of attributes is when it comes to describing properties for the property explorer in Visual Studio.net.
using System;
using System.ComponentModel;
namespace Examples
{
public class ExampleControl : UserControl
{
private IndentStyle m_eExampleProperty = IndentStyle.Smart;
[
Category("Design"),
Description("Gets/sets an example value."),
DefaultValue(IndentStyle.Smart),
Browsable(true)
]
public IndentStyle ExampleProperty
{
get
{
return m_eExampleProperty;
}
set
{
m_eExampleProperty = value;
}
}
}
}
This would produce this kind of output:
If you want to try this out, just cut-and-paste the code into a source file, and create an instance of the control on the designer form.
- Daniël Pelsmaeker
Microsoft is to quality software what McDonalds is to gourmet cooking
|
|
|
|
|
I need some help getting my puter setup to run ASP.NET apps. I have IIS installed and the Web Publishing is running. I have also shared the folder where the app is. I keep getting an error:
"http://localhost/<name> HTTP 500 internal error!
Real informative! Can anyone give me some suggestions on what needs to be running?
Thanks
Larry J. Siddens
|
|
|
|
|
Well, for one, you need to install ASP.NET with the .NET Framework. If you're having problems, you should run "aspnet_regiis.exe /i". Read more about aspnet_regiis.exe in the .NET Framework SDK documentation. There's some other options.
Another possibility is that your ASP.NET page - or your IIS extension mappings - have an error and are causing a server error. Without knowing more, it's hard to say. The error says it all: server error. Millions of things could be wrong.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hey, new message!
Unable to open Web project "project name". The file path <path> does not correspond to URL 'http://Localhost:/<project name>'. the two need to map to the same server location. HTTP Error 403: Access.
I get this when I open a project under C#!
Larry J. Siddens
|
|
|
|
|
HTTP error code 403 is access denied. Check your filesystem permissions and make sure that the account under which ASP.NET runs (by default, a local user named ASPNET) has permissions to at least read and list the files and directories. Also make sure that your account has read/write permissions.
Second, you must already have a project in the web application (in this case, the root application on 'localhost'). If you do, you might try typing the name in, like 'http://localhost/project.csproj'. Sometimes VS.NET doesn't show directories correctly, but I've really only experience this with remote servers on a different network (like opening up a project at work from home).
Finally, the project in 'http://localhost' has to have that host in the project file itself. The project file is just an XML file so browse to the directory in which your project is located (for example, 'C:\Inetpub\wwwroot'), open it up in notepad or some other vanilla text editor, and change the host to match the location in which you're trying to open it.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
|
I'm having a problem with shared assemblies > 2^16 bytes in size.
My assembly is in a solution along with a console app that references the
assembly. The app is set up to reference the assembly (the reference path
is pointed to the assemblies output directory). When I do a build, the
assembly is failing to build because the .dll is loaded. If I remove the console app's
reference to the assembly everything is fine.
I'm getting the following output from the build:
The file 'Test_Library.dll' cannot be copied to the run directory. The
process cannot access the file because it is being used by another process.
Could not copy temporary files to the output directory.
I've created a few other shared assemblies with no problems. This is the
first time I've seen this exact problem and in trying to run it down I've
discovered that if the .dll's size is < 65536 bytes (as all my other ones
are), this doesn't happen. It looks like VS is loading the .dll when I add
the reference for the console app. If I delete the console app's reference
to the assembly, I am able to build the library.
I hope one of you has run across this before.
thanks for any help
|
|
|
|
|
Yes, and it's definitely a bug in VS.NET. One thing that helps eliminate the problem is to use a Project reference instead of a file reference. When adding the reference to a project in your solution to another project, click on the Projects tab in your Add Reference dialog. Select the project. This not only helps eliminate the problem a little, but it also ensures that whenever you make a build of your library/application, that the proper build of the dependency is created as well. For instance, when you create a Debug build all dependencies are built in debug mode.
When this problem occurs, pretty much all you can do is make sure that your application isn't running (use the Process tab in the Task Manager to really make sure - just because you can't see it doesn't mean it's not running) and restart VS.NET to get it to release the lock on the executable(s).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|