Hello! I just wonder how can this small code fragment work when I have Main method as private. How can the runtime part(CLR) access main method when it is private. public class myApp { private static void Main() { System.Console.WriteLine("Main is now private "); } } //Tony
Tony_Joh
Posts
-
How can Main be a private method -
Vad menas med detta [DefaultValue(false)]?Hej! Jag har en kod snutt här nedan där man sätter showDropDownButtons = false. Även om man inte gjorde det skulle showDropDownButtons vara initierat till false eftersom default initiering för bool är false. Jag har testat lite och även om jag skulle byta ut dennna [DefaultValue(false)] mot denna [DefaultValue(true)] skulle ShowDropDownButtons vara false. Uttrycket [DefaultValue(true)] utför allså ingen initiering. Jag kan inte förstå vad uttrycket [DefaultValue(false)] eller [DefaultValue(true)] har för någon nytta. Det fungerar precis lika bra om man utelämnar denna [DefaultValue(false)]. public class AdvPropertyColumn : PropertyEditColumn { public AdvPropertyColumn(string caption) : base(caption){} //konstructor private bool showDropDownButtons = false; [DefaultValue(false)] public bool ShowDropDownButtons { get { return showDropDownButtons; } set { if (showDropDownButtons != value) { Console.WriteLine("AdvPropertyColumn.Set.ShowDropDownButtons [showDropDownButtons != value]"); showDropDownButtons = value; base.OnChanged(InvalidationMode.ColumnWithoutHeader, false); } } }//end property ShowDropDownButton } //Tony
-
Can't find a class library dll in design modeHello! I have one solution file that consist of three project. One project that build a user control dll. In this user control we have a class called B One project that build a class library dll. In this class library we have a class called C In the user control project I have a project reference to the class library. I build the user control dll and this class library successfully. This user control dll is added to the Toolbox. In the constructor for this class B is a call to instansiate a class C in the class library. When I add this user control to the Toolbox I use directory obj/debug to select the user control dll. So adding the user control works fine. When I drag this user control from the Toolbox into a form that exist in the project that build the exe file object B will be instansiated and another object which is class C will also be instansiated that exist in the class library. Like this. public B() { InitializeComponent(); Last.C last = new Last.C(); last.foo(); } In design mode when we want to design a form that exist in the project that build the exe file we have one dependency the user control is dependent of the class library because an instance of class C will be instansiated as I mentioned before. Now to my problem when I try to drag the user control from the toolbox into a form that exist in the project that build the exe file which search path is used to locate the class library dll because I get this error "An exception occured while trying to create an instance of WindowsControlLibrary.B. The execption was "?"." probably because the class library can't be found. Where should I look and what should I do? I'm rather new to using user control dll and class library. One more additional information is when I drag the use control into a form a get the error message and at the same time two references are added which is the class library dll and the user control dll If I look at the reference path for the class library that was added I discover that my class library exist in this directory. If I look at the reference path for the user control library that was added I discover that my user control library exist in this directory. The two added reference path are the same. //Tony
-
Have problemS with windows control dllHello! I have one solution file that consist of three project. One project that build the exe file. One project that build a class library dll One project that build a windows control dll In the windows control c-tor is there a call to a method in the class libarary. So in the project referense settings for the windows control I have a project referens to the class library. In the exe file c-tor I have a call to a method in the class library. So in the project reference settings for the exe file I have a project reference to the class library and to the windows control because I can drag the windows control from the toolbox to a form in the project that build the exe file. Now to my problem if I now rebuild the project only for the class library and then try to drag the windows control to a form I get the following error "An exception occured while trying to create an instance of Middle.Middle. The execption was "?"." But if I rebuild the windows control instead then I can drag the windows control from the toolbox to a form in the project that build the exe file. My first question why do I get this error. My second question is what is the recommended setting for copy local that exist on each project. It it to have true or false. My third question is what requirement is it about the version that each dll have. I mean when an exe file will call a dll or when a dll will call another dll. //Tony
-
Get this compile error "Could not copy temporary files to the output directory."Hello! I use VS 2003 and C# When I build an exe file that use 6 class library dll I get this error. Could not copy temporary files to the output directory. The file 'MeltPracStorage.dll' cannot be copied to the run directory. Det går inte att komma åt filen eftersom den används av en annan process. All six project is located in the solution that build the exe file This compile error occurred when I add project 'MeltPracStorage to the solution. I use copy local=true If I have this MeltPracStorage in a solution of its own and only reference the class dll MeltPracStorage.dll in the reference list for the project that build the exe file I don't get any errors. The MeltPracStorage.dll size is 176 kB Have you any kind of suggestion to ny problem. //Tony
-
How do I add existing visual Item to a projectHello!! Normally I use C# but we have a project that is creating a window control library DLL that is done in C++.NET and that is here I have some problems that I want to solve. To be able to understand my question fully, I do the following. 1. Create a project that is a WindowControlLibrary called Test in C++.NET in this project we have several files but the following are intresting for me. Under Source Files we have a file called TestControl.cpp Under Header Files we have a file called TestControl.h and if you expand this file you can see TestControl.resX. 2.Open View Designer for TestControl.h and add for example a button. 3. Everything works as it should so far. 4. Now delete file TestControl.cpp and TestControl.h from the project Test. When file TestControl.h was deleted, file TestControl.resX was also deleted because it was connected to TestControl.h 5. The files still exist in folder Test but does not exist in project Test. 6 Now assume that you want to add these files(TestControl.cpp, TestControl.h and TestControl.resX) back into project Test again. 7 I have tried different variation for Add Existing Item for my three files to project Test but all my attempts failed in the way that I can never open View Designor. 8 So how do I do if I want to add an existing visual control like the TestControl. 9 It works perfectly to add new Item which I do in this way click on Source File and select add New Item and choose for example User Control. //Tony
-
Having problem with class decaration when Building a class librarayHello! Here below I have been more specific to my problem. I thing that you can understand what my problem is. I'm trying to build a class library which has a class called AvestaPlantFunc. In this project building a class libray exist a class called AvestaPlantFunc. In this class is there a method called IsBottomMixValid. Code not relevant for the question has been removed. This method IsBottomMixValid has one parameter and the type for this parameter is MeltPracDataGmix meaning passing class reference MeltPracDataGmix. Now to my question the definition for class MeltPracDataGmix does not exist in the same project as the class AvestaPlantFunc. Class MeltPracDataGmix exist in another project that build the exe file. When a class has a reference to another class as in my example is it nesessary that the full definition to class MeltPracDataGmix is existing in the same project. I assume if this was C++ it would be enough to include the class declaration which is the header file and not the implementation. But in C# we don't have any header files. So how do I do here? What is the solution to this problem when the class need another class. using System; using MeltPracData; namespace Common { public class AvestaPlantFunc { public bool IsBottomMixValid(MeltPracDataGmix mix) { //here is there some code } } } //Tony
-
Having problem with class decaration when Building a class librarayHello! I try to build a class library but I run into some problems. In the code for this class library there are some rows that have this kind of look public bool IsBottomMixValid(MeltPracDataGmix.BottomBlowing mix, int maxBottomFlow) As you can see here we have a class named MeltPracDataGmix that exist in the code for the project that build the actual exe file. So the class definition does not exist in this project for this class library. My qustion is what is the solution to this kind of problem. I assume if this was C++ it would be enough to include the class declaration which is the header file. But in C# we don't have any header files. So how do I do here? //Tony
-
Why is my inherited window forms control deletedHello! I have a very specific question and that is about how to inherit a visual control for example the control System.Windows.Forms.TextBox without causing the environment to delete the control when there are some compile errors. It's the same problem with any visual control that you inherit. The control is deleted as soon as you use the View Designer when there is compile error. It's very easy to reproduce my problem. You can do it in this way. 1. Create a class called ExtTextBox like this. In my example here I have removed the namespace. But if you include namespace make sure you have access to it. public class ExtTextBox : System.Windows.Forms.TextBox { public ExtTextBox() {} } As you can see this class ExtTextBox inherit from the ordinary components System.Windows.Forms.TextBox in the .NET framework 2. Create a windows form with any name. The default is Form1 3. Use the View Designer and drag the control TextBox into the window form. My control was called textBox1 4. Because I want the control textBox1 to be an instance of ExtTextBox I have to edit the InitializeComponent() I don't have any other idea. Here is an extract from my windows form called Form1. Only the interesting rows is written. Two rows is important here. First saying that control textBox1 is of type ExtTextBox. Second edit the InitializeComponent and say that textBox1 is an instance of ExtTextBox. public class Form1 : Form { private ExtTextBox textBox1; ... ... ... Private void InitializeComponent() { this.textBox1= new ExtTextBox(); ... ... ... } } 5 Compile. Hopefully you don't get any compile errors. When you run the application only the textBox is being displayed. The problem might start even here. If you get any compile error and you use the View Designer the control named textBox1 is being deleted. 6 If you don't get any compile error make a change so you get a compile error and then use the View Designer the control named textBox1 is being deleted. 7 Now to my question. I can't use controls that being deleted automatically when I get compile error as soon as I use the View Designer. 8. If I want to use inheritance on visual control how do I do. I just can't have it as it is now. 9 I just can't use inheritance in the way I do now. 10. I hope that you have a good suggestion how I should use inheritance on visual control to avoid this kind of problems. Additional inform
-
window forms control is automatically deletedHello!! Thanks for your answer. I use VS 2003. I can't understand how your solution can solve my problem. Can you be be specific. //Tony
-
window forms control is automatically deletedHello! I have a very specific question and that is about how to inherit a control for example the control System.Windows.Forms.TextBox without causing the environment to delete the control when there are some compile errors. It's the same problem with any visual control that you inherit. The control is deleted as soon as you use the View Designer when there is compile error. It's very easy to reproduce my problem. You can do it in this way. 1. Create a class called ExtTextBox like this. In my example here I have removed the namespace. But if you include namespace make sure you have access to it. public class ExtTextBox : System.Windows.Forms.TextBox { public ExtTextBox() {} } As you can see this class ExtTextBox inherit from the ordinary components System.Windows.Forms.TextBox in the .NET framework 2. Create a windows form with any name. The default is Form1 3. Use the View Designer and create the control TextBox in the window form. My control was called textBox1 4. Because I want the control textBox1 to be an instance of ExtTextBox I have to edit the InitializeComponent() I don't have any other idea. Here is an extract from my windows form called Form1. Only the interesting rows is written. Two rows are important here. First saying that control textBox1 is of type ExtTextBox. Second edit the InitializeComponent and say that textBox1 is an instance of ExtTextBox. public class Form1 : Form { private ExtTextBox textBox1; // First saying that control textBox1 is of type ExtTextBox. ... ... ... Private void InitializeComponent() { //Second edit the InitializeComponent and say that textBox1 is an instance of ExtTextBox this.textBox1= new ExtTextBox(); ... ... ... } } 5 Compile. Hopefully you don't get any compile errors. When you run the application only the textBox is being displayed. The problem might start even here. If you get any compile error and you use the View Designer the control named textBox1 is being deleted automatically. 6 If you don't get any compile error make a change so you get a compile error and then use the View Designer the control named textBox1 is being deleted automatically. 7 Now to my question. I can't use controls that being deleted automatically when I get compile error. 8. If I want to use inheritance on visual control how do I do. I just can't have it as it is now. 9 I just can't use inheritance in the way I do now. 10. I hope that you have a
-
How do I use one form showing to different lookHello!! The main point is to avoid having to duplicate the code but if I use your suggestion then the code will be duplicated when I have two forms. If I understand you right as you say these will be two separate application having it's own lives with it's own form. Assume instead that the form between two customer were identical accept the colour on one single button. Do you still suggest that the best suggestion is to have two different application with it's own form. I don't know if you are familiar with MFC but as I mentioned in the previous mail this is easy to solve in MFC. So do you think that there doesn't exist any solution which is as good as the MFC solution of this problem. If I just mention resource files. Resource files is having a different meaning and purpose in .Net compare to MFC. So to use resource files to solve my problem is not posssible in .NET(C#). //Tony
-
How do I use one form showing to different lookHello!! I'm using C# Assume I have an application containing a form named form.cs. When you create the look for the form you use the form designer to construct the look that you want. All changes that you do in form designer are put into method InitializeComponent. Assume the form have many more controls than these three controls mentioned just below. The controls that are interesting for my question are: Two buttons called put_in_box and get_from_box. One label showing the correct time. One datagrid. The property for these controls is located in the InitializeComponent as I mentioned earlier. Assume another customer requirement on the form is quite similar to form form.cs. The only difference is that some controls should not be displayed and some other controls be added instead. The followings controls should not be displyed for the new customer. The two buttons named put_in_box and get_from_box. A label showing current time. A datagrid. The new customer want to have a combobox in the same location as the datagrid. We can assume that if you compare the appearance of the form between the two customer much is the same. Now to my problem. 1. I want to have only one form in this case form.cs. So no duplication of code. 2. In an easy way being able to have two appearance(look) of the same form which is named form.cs. 3. Being able to change the appearance(look) for any of these two customer in an easy way.. 4.The form designor is always looking for InitializeComponent when you want to change the appearance(the look) for the form. 5. If I had used MFC I would have used the resource files which store the look for a form in a named resource file. One customers look had been stored in one resource file and the other customer look would have been stored in another resource file but the code would only be in one place so no duplicate code I can't find any good solution to my problem. - One solution which is bad is to have two forms having one form for each customer which also duplicate the code. For example having form.cs and form_xyz.cs - Another solution which is very bad is to have two InitializeComponent InitializeComponent_abc and InitializeComponent_xyz. One for each customer. When you want to edit the appearance(the look) for a customer xyz you have to rename InitializeComponent_xyz to InitializeComponent because the form designed is always looking for InitializeComponent. As a summary a lot of renaming here and there. I wonder if you could help me w